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

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

31,660 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 need to be wrapped in an IIFE because it need to be in strict mode.
1451 (() => {
1452 "use strict";
1453 // ESM COMPAT FLAG
1454 __webpack_require__.r(__webpack_exports__);
1455
1456 // EXPORTS
1457 __webpack_require__.d(__webpack_exports__, {
1458 AlignmentToolbar: () => (/* reexport */ AlignmentToolbar),
1459 Autocomplete: () => (/* reexport */ Autocomplete),
1460 AutosaveMonitor: () => (/* reexport */ autosave_monitor),
1461 BlockAlignmentToolbar: () => (/* reexport */ BlockAlignmentToolbar),
1462 BlockControls: () => (/* reexport */ BlockControls),
1463 BlockEdit: () => (/* reexport */ BlockEdit),
1464 BlockEditorKeyboardShortcuts: () => (/* reexport */ BlockEditorKeyboardShortcuts),
1465 BlockFormatControls: () => (/* reexport */ BlockFormatControls),
1466 BlockIcon: () => (/* reexport */ BlockIcon),
1467 BlockInspector: () => (/* reexport */ BlockInspector),
1468 BlockList: () => (/* reexport */ BlockList),
1469 BlockMover: () => (/* reexport */ BlockMover),
1470 BlockNavigationDropdown: () => (/* reexport */ BlockNavigationDropdown),
1471 BlockSelectionClearer: () => (/* reexport */ BlockSelectionClearer),
1472 BlockSettingsMenu: () => (/* reexport */ BlockSettingsMenu),
1473 BlockTitle: () => (/* reexport */ BlockTitle),
1474 BlockToolbar: () => (/* reexport */ BlockToolbar),
1475 CharacterCount: () => (/* reexport */ CharacterCount),
1476 ColorPalette: () => (/* reexport */ ColorPalette),
1477 ContrastChecker: () => (/* reexport */ ContrastChecker),
1478 CopyHandler: () => (/* reexport */ CopyHandler),
1479 DefaultBlockAppender: () => (/* reexport */ DefaultBlockAppender),
1480 DocumentBar: () => (/* reexport */ DocumentBar),
1481 DocumentOutline: () => (/* reexport */ DocumentOutline),
1482 DocumentOutlineCheck: () => (/* reexport */ DocumentOutlineCheck),
1483 EditorHistoryRedo: () => (/* reexport */ editor_history_redo),
1484 EditorHistoryUndo: () => (/* reexport */ editor_history_undo),
1485 EditorKeyboardShortcuts: () => (/* reexport */ EditorKeyboardShortcuts),
1486 EditorKeyboardShortcutsRegister: () => (/* reexport */ register_shortcuts),
1487 EditorNotices: () => (/* reexport */ editor_notices),
1488 EditorProvider: () => (/* reexport */ provider),
1489 EditorSnackbars: () => (/* reexport */ EditorSnackbars),
1490 EntitiesSavedStates: () => (/* reexport */ EntitiesSavedStates),
1491 ErrorBoundary: () => (/* reexport */ error_boundary),
1492 FontSizePicker: () => (/* reexport */ FontSizePicker),
1493 InnerBlocks: () => (/* reexport */ InnerBlocks),
1494 Inserter: () => (/* reexport */ Inserter),
1495 InspectorAdvancedControls: () => (/* reexport */ InspectorAdvancedControls),
1496 InspectorControls: () => (/* reexport */ InspectorControls),
1497 LocalAutosaveMonitor: () => (/* reexport */ local_autosave_monitor),
1498 MediaPlaceholder: () => (/* reexport */ MediaPlaceholder),
1499 MediaUpload: () => (/* reexport */ MediaUpload),
1500 MediaUploadCheck: () => (/* reexport */ MediaUploadCheck),
1501 MultiSelectScrollIntoView: () => (/* reexport */ MultiSelectScrollIntoView),
1502 NavigableToolbar: () => (/* reexport */ NavigableToolbar),
1503 ObserveTyping: () => (/* reexport */ ObserveTyping),
1504 PageAttributesCheck: () => (/* reexport */ page_attributes_check),
1505 PageAttributesOrder: () => (/* reexport */ PageAttributesOrderWithChecks),
1506 PageAttributesPanel: () => (/* reexport */ PageAttributesPanel),
1507 PageAttributesParent: () => (/* reexport */ page_attributes_parent),
1508 PageTemplate: () => (/* reexport */ classic_theme),
1509 PanelColorSettings: () => (/* reexport */ PanelColorSettings),
1510 PlainText: () => (/* reexport */ PlainText),
1511 PluginBlockSettingsMenuItem: () => (/* reexport */ plugin_block_settings_menu_item),
1512 PluginDocumentSettingPanel: () => (/* reexport */ plugin_document_setting_panel),
1513 PluginMoreMenuItem: () => (/* reexport */ 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 */ post_format_check),
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 PostSlug: () => (/* reexport */ PostSlug),
1550 PostSlugCheck: () => (/* reexport */ PostSlugCheck),
1551 PostSticky: () => (/* reexport */ PostSticky),
1552 PostStickyCheck: () => (/* reexport */ PostStickyCheck),
1553 PostSwitchToDraftButton: () => (/* reexport */ PostSwitchToDraftButton),
1554 PostSyncStatus: () => (/* reexport */ PostSyncStatus),
1555 PostTaxonomies: () => (/* reexport */ post_taxonomies),
1556 PostTaxonomiesCheck: () => (/* reexport */ PostTaxonomiesCheck),
1557 PostTaxonomiesFlatTermSelector: () => (/* reexport */ FlatTermSelector),
1558 PostTaxonomiesHierarchicalTermSelector: () => (/* reexport */ HierarchicalTermSelector),
1559 PostTaxonomiesPanel: () => (/* reexport */ post_taxonomies_panel),
1560 PostTemplatePanel: () => (/* reexport */ PostTemplatePanel),
1561 PostTextEditor: () => (/* reexport */ PostTextEditor),
1562 PostTitle: () => (/* reexport */ post_title),
1563 PostTitleRaw: () => (/* reexport */ post_title_raw),
1564 PostTrash: () => (/* reexport */ PostTrash),
1565 PostTrashCheck: () => (/* reexport */ PostTrashCheck),
1566 PostTypeSupportCheck: () => (/* reexport */ post_type_support_check),
1567 PostURL: () => (/* reexport */ PostURL),
1568 PostURLCheck: () => (/* reexport */ PostURLCheck),
1569 PostURLLabel: () => (/* reexport */ PostURLLabel),
1570 PostURLPanel: () => (/* reexport */ PostURLPanel),
1571 PostVisibility: () => (/* reexport */ PostVisibility),
1572 PostVisibilityCheck: () => (/* reexport */ PostVisibilityCheck),
1573 PostVisibilityLabel: () => (/* reexport */ PostVisibilityLabel),
1574 RichText: () => (/* reexport */ RichText),
1575 RichTextShortcut: () => (/* reexport */ RichTextShortcut),
1576 RichTextToolbarButton: () => (/* reexport */ RichTextToolbarButton),
1577 ServerSideRender: () => (/* reexport */ (external_wp_serverSideRender_default())),
1578 SkipToSelectedBlock: () => (/* reexport */ SkipToSelectedBlock),
1579 TableOfContents: () => (/* reexport */ table_of_contents),
1580 TextEditorGlobalKeyboardShortcuts: () => (/* reexport */ TextEditorGlobalKeyboardShortcuts),
1581 ThemeSupportCheck: () => (/* reexport */ ThemeSupportCheck),
1582 TimeToRead: () => (/* reexport */ TimeToRead),
1583 URLInput: () => (/* reexport */ URLInput),
1584 URLInputButton: () => (/* reexport */ URLInputButton),
1585 URLPopover: () => (/* reexport */ URLPopover),
1586 UnsavedChangesWarning: () => (/* reexport */ UnsavedChangesWarning),
1587 VisualEditorGlobalKeyboardShortcuts: () => (/* reexport */ VisualEditorGlobalKeyboardShortcuts),
1588 Warning: () => (/* reexport */ Warning),
1589 WordCount: () => (/* reexport */ WordCount),
1590 WritingFlow: () => (/* reexport */ WritingFlow),
1591 __unstableRichTextInputEvent: () => (/* reexport */ __unstableRichTextInputEvent),
1592 cleanForSlug: () => (/* reexport */ cleanForSlug),
1593 createCustomColorsHOC: () => (/* reexport */ createCustomColorsHOC),
1594 getColorClassName: () => (/* reexport */ getColorClassName),
1595 getColorObjectByAttributeValues: () => (/* reexport */ getColorObjectByAttributeValues),
1596 getColorObjectByColorValue: () => (/* reexport */ getColorObjectByColorValue),
1597 getFontSize: () => (/* reexport */ getFontSize),
1598 getFontSizeClass: () => (/* reexport */ getFontSizeClass),
1599 getTemplatePartIcon: () => (/* reexport */ getTemplatePartIcon),
1600 mediaUpload: () => (/* reexport */ mediaUpload),
1601 privateApis: () => (/* reexport */ privateApis),
1602 registerEntityAction: () => (/* reexport */ api_registerEntityAction),
1603 store: () => (/* reexport */ store_store),
1604 storeConfig: () => (/* reexport */ storeConfig),
1605 transformStyles: () => (/* reexport */ external_wp_blockEditor_namespaceObject.transformStyles),
1606 unregisterEntityAction: () => (/* reexport */ api_unregisterEntityAction),
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 trashPost: () => (trashPost),
1808 undo: () => (undo),
1809 unlockPostAutosaving: () => (unlockPostAutosaving),
1810 unlockPostSaving: () => (unlockPostSaving),
1811 updateBlock: () => (updateBlock),
1812 updateBlockAttributes: () => (updateBlockAttributes),
1813 updateBlockListSettings: () => (updateBlockListSettings),
1814 updateEditorSettings: () => (updateEditorSettings),
1815 updatePost: () => (updatePost),
1816 updatePostLock: () => (updatePostLock)
1817 });
1818
1819 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-actions.js
1820 var store_private_actions_namespaceObject = {};
1821 __webpack_require__.r(store_private_actions_namespaceObject);
1822 __webpack_require__.d(store_private_actions_namespaceObject, {
1823 createTemplate: () => (createTemplate),
1824 hideBlockTypes: () => (hideBlockTypes),
1825 registerEntityAction: () => (registerEntityAction),
1826 registerPostTypeActions: () => (registerPostTypeActions),
1827 removeTemplates: () => (removeTemplates),
1828 revertTemplate: () => (private_actions_revertTemplate),
1829 saveDirtyEntities: () => (saveDirtyEntities),
1830 setCurrentTemplateId: () => (setCurrentTemplateId),
1831 setIsReady: () => (setIsReady),
1832 showBlockTypes: () => (showBlockTypes),
1833 unregisterEntityAction: () => (unregisterEntityAction)
1834 });
1835
1836 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-selectors.js
1837 var store_private_selectors_namespaceObject = {};
1838 __webpack_require__.r(store_private_selectors_namespaceObject);
1839 __webpack_require__.d(store_private_selectors_namespaceObject, {
1840 getEntityActions: () => (private_selectors_getEntityActions),
1841 getInserter: () => (getInserter),
1842 getInserterSidebarToggleRef: () => (getInserterSidebarToggleRef),
1843 getListViewToggleRef: () => (getListViewToggleRef),
1844 getPostBlocksByName: () => (getPostBlocksByName),
1845 getPostIcon: () => (getPostIcon),
1846 hasPostMetaChanges: () => (hasPostMetaChanges),
1847 isEntityReady: () => (private_selectors_isEntityReady)
1848 });
1849
1850 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
1851 var store_actions_namespaceObject = {};
1852 __webpack_require__.r(store_actions_namespaceObject);
1853 __webpack_require__.d(store_actions_namespaceObject, {
1854 closeModal: () => (closeModal),
1855 disableComplementaryArea: () => (disableComplementaryArea),
1856 enableComplementaryArea: () => (enableComplementaryArea),
1857 openModal: () => (openModal),
1858 pinItem: () => (pinItem),
1859 setDefaultComplementaryArea: () => (setDefaultComplementaryArea),
1860 setFeatureDefaults: () => (setFeatureDefaults),
1861 setFeatureValue: () => (setFeatureValue),
1862 toggleFeature: () => (toggleFeature),
1863 unpinItem: () => (unpinItem)
1864 });
1865
1866 // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
1867 var store_selectors_namespaceObject = {};
1868 __webpack_require__.r(store_selectors_namespaceObject);
1869 __webpack_require__.d(store_selectors_namespaceObject, {
1870 getActiveComplementaryArea: () => (getActiveComplementaryArea),
1871 isComplementaryAreaLoading: () => (isComplementaryAreaLoading),
1872 isFeatureActive: () => (isFeatureActive),
1873 isItemPinned: () => (isItemPinned),
1874 isModalActive: () => (isModalActive)
1875 });
1876
1877 // NAMESPACE OBJECT: ./packages/interface/build-module/index.js
1878 var build_module_namespaceObject = {};
1879 __webpack_require__.r(build_module_namespaceObject);
1880 __webpack_require__.d(build_module_namespaceObject, {
1881 ActionItem: () => (action_item),
1882 ComplementaryArea: () => (complementary_area),
1883 ComplementaryAreaMoreMenuItem: () => (ComplementaryAreaMoreMenuItem),
1884 FullscreenMode: () => (fullscreen_mode),
1885 InterfaceSkeleton: () => (interface_skeleton),
1886 NavigableRegion: () => (navigable_region),
1887 PinnedItems: () => (pinned_items),
1888 store: () => (store)
1889 });
1890
1891 ;// external ["wp","data"]
1892 const external_wp_data_namespaceObject = window["wp"]["data"];
1893 ;// external ["wp","coreData"]
1894 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
1895 ;// external ["wp","element"]
1896 const external_wp_element_namespaceObject = window["wp"]["element"];
1897 ;// external ["wp","compose"]
1898 const external_wp_compose_namespaceObject = window["wp"]["compose"];
1899 ;// external ["wp","hooks"]
1900 const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
1901 ;// external ["wp","blockEditor"]
1902 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
1903 ;// ./packages/editor/build-module/store/defaults.js
1904 /**
1905 * WordPress dependencies
1906 */
1907
1908
1909 /**
1910 * The default post editor settings.
1911 *
1912 * @property {boolean|Array} allowedBlockTypes Allowed block types
1913 * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
1914 * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
1915 * @property {boolean} fontLibraryEnabled Whether the font library is enabled or not.
1916 * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
1917 * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
1918 * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
1919 * 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.
1920 * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
1921 * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
1922 * @property {Array?} availableTemplates The available post templates
1923 * @property {boolean} disablePostFormats Whether or not the post formats are disabled
1924 * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
1925 * @property {number} maxUploadFileSize Maximum upload file size
1926 * @property {boolean} supportsLayout Whether the editor supports layouts.
1927 */
1928 const EDITOR_SETTINGS_DEFAULTS = {
1929 ...external_wp_blockEditor_namespaceObject.SETTINGS_DEFAULTS,
1930 richEditingEnabled: true,
1931 codeEditingEnabled: true,
1932 fontLibraryEnabled: true,
1933 enableCustomFields: undefined,
1934 defaultRenderingMode: 'post-only'
1935 };
1936
1937 ;// ./packages/editor/build-module/dataviews/store/reducer.js
1938 /**
1939 * WordPress dependencies
1940 */
1941
1942 function isReady(state = {}, action) {
1943 switch (action.type) {
1944 case 'SET_IS_READY':
1945 return {
1946 ...state,
1947 [action.kind]: {
1948 ...state[action.kind],
1949 [action.name]: true
1950 }
1951 };
1952 }
1953 return state;
1954 }
1955 function actions(state = {}, action) {
1956 var _state$action$kind$ac;
1957 switch (action.type) {
1958 case 'REGISTER_ENTITY_ACTION':
1959 return {
1960 ...state,
1961 [action.kind]: {
1962 ...state[action.kind],
1963 [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]
1964 }
1965 };
1966 case 'UNREGISTER_ENTITY_ACTION':
1967 {
1968 var _state$action$kind$ac2;
1969 return {
1970 ...state,
1971 [action.kind]: {
1972 ...state[action.kind],
1973 [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)
1974 }
1975 };
1976 }
1977 }
1978 return state;
1979 }
1980 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
1981 actions,
1982 isReady
1983 }));
1984
1985 ;// ./packages/editor/build-module/store/reducer.js
1986 /**
1987 * WordPress dependencies
1988 */
1989
1990
1991 /**
1992 * Internal dependencies
1993 */
1994
1995
1996
1997 /**
1998 * Returns a post attribute value, flattening nested rendered content using its
1999 * raw value in place of its original object form.
2000 *
2001 * @param {*} value Original value.
2002 *
2003 * @return {*} Raw value.
2004 */
2005 function getPostRawValue(value) {
2006 if (value && 'object' === typeof value && 'raw' in value) {
2007 return value.raw;
2008 }
2009 return value;
2010 }
2011
2012 /**
2013 * Returns true if the two object arguments have the same keys, or false
2014 * otherwise.
2015 *
2016 * @param {Object} a First object.
2017 * @param {Object} b Second object.
2018 *
2019 * @return {boolean} Whether the two objects have the same keys.
2020 */
2021 function hasSameKeys(a, b) {
2022 const keysA = Object.keys(a).sort();
2023 const keysB = Object.keys(b).sort();
2024 return keysA.length === keysB.length && keysA.every((key, index) => keysB[index] === key);
2025 }
2026
2027 /**
2028 * Returns true if, given the currently dispatching action and the previously
2029 * dispatched action, the two actions are editing the same post property, or
2030 * false otherwise.
2031 *
2032 * @param {Object} action Currently dispatching action.
2033 * @param {Object} previousAction Previously dispatched action.
2034 *
2035 * @return {boolean} Whether actions are updating the same post property.
2036 */
2037 function isUpdatingSamePostProperty(action, previousAction) {
2038 return action.type === 'EDIT_POST' && hasSameKeys(action.edits, previousAction.edits);
2039 }
2040
2041 /**
2042 * Returns true if, given the currently dispatching action and the previously
2043 * dispatched action, the two actions are modifying the same property such that
2044 * undo history should be batched.
2045 *
2046 * @param {Object} action Currently dispatching action.
2047 * @param {Object} previousAction Previously dispatched action.
2048 *
2049 * @return {boolean} Whether to overwrite present state.
2050 */
2051 function shouldOverwriteState(action, previousAction) {
2052 if (action.type === 'RESET_EDITOR_BLOCKS') {
2053 return !action.shouldCreateUndoLevel;
2054 }
2055 if (!previousAction || action.type !== previousAction.type) {
2056 return false;
2057 }
2058 return isUpdatingSamePostProperty(action, previousAction);
2059 }
2060 function postId(state = null, action) {
2061 switch (action.type) {
2062 case 'SET_EDITED_POST':
2063 return action.postId;
2064 }
2065 return state;
2066 }
2067 function templateId(state = null, action) {
2068 switch (action.type) {
2069 case 'SET_CURRENT_TEMPLATE_ID':
2070 return action.id;
2071 }
2072 return state;
2073 }
2074 function postType(state = null, action) {
2075 switch (action.type) {
2076 case 'SET_EDITED_POST':
2077 return action.postType;
2078 }
2079 return state;
2080 }
2081
2082 /**
2083 * Reducer returning whether the post blocks match the defined template or not.
2084 *
2085 * @param {Object} state Current state.
2086 * @param {Object} action Dispatched action.
2087 *
2088 * @return {boolean} Updated state.
2089 */
2090 function template(state = {
2091 isValid: true
2092 }, action) {
2093 switch (action.type) {
2094 case 'SET_TEMPLATE_VALIDITY':
2095 return {
2096 ...state,
2097 isValid: action.isValid
2098 };
2099 }
2100 return state;
2101 }
2102
2103 /**
2104 * Reducer returning current network request state (whether a request to
2105 * the WP REST API is in progress, successful, or failed).
2106 *
2107 * @param {Object} state Current state.
2108 * @param {Object} action Dispatched action.
2109 *
2110 * @return {Object} Updated state.
2111 */
2112 function saving(state = {}, action) {
2113 switch (action.type) {
2114 case 'REQUEST_POST_UPDATE_START':
2115 case 'REQUEST_POST_UPDATE_FINISH':
2116 return {
2117 pending: action.type === 'REQUEST_POST_UPDATE_START',
2118 options: action.options || {}
2119 };
2120 }
2121 return state;
2122 }
2123
2124 /**
2125 * Reducer returning deleting post request state.
2126 *
2127 * @param {Object} state Current state.
2128 * @param {Object} action Dispatched action.
2129 *
2130 * @return {Object} Updated state.
2131 */
2132 function deleting(state = {}, action) {
2133 switch (action.type) {
2134 case 'REQUEST_POST_DELETE_START':
2135 case 'REQUEST_POST_DELETE_FINISH':
2136 return {
2137 pending: action.type === 'REQUEST_POST_DELETE_START'
2138 };
2139 }
2140 return state;
2141 }
2142
2143 /**
2144 * Post Lock State.
2145 *
2146 * @typedef {Object} PostLockState
2147 *
2148 * @property {boolean} isLocked Whether the post is locked.
2149 * @property {?boolean} isTakeover Whether the post editing has been taken over.
2150 * @property {?boolean} activePostLock Active post lock value.
2151 * @property {?Object} user User that took over the post.
2152 */
2153
2154 /**
2155 * Reducer returning the post lock status.
2156 *
2157 * @param {PostLockState} state Current state.
2158 * @param {Object} action Dispatched action.
2159 *
2160 * @return {PostLockState} Updated state.
2161 */
2162 function postLock(state = {
2163 isLocked: false
2164 }, action) {
2165 switch (action.type) {
2166 case 'UPDATE_POST_LOCK':
2167 return action.lock;
2168 }
2169 return state;
2170 }
2171
2172 /**
2173 * Post saving lock.
2174 *
2175 * When post saving is locked, the post cannot be published or updated.
2176 *
2177 * @param {PostLockState} state Current state.
2178 * @param {Object} action Dispatched action.
2179 *
2180 * @return {PostLockState} Updated state.
2181 */
2182 function postSavingLock(state = {}, action) {
2183 switch (action.type) {
2184 case 'LOCK_POST_SAVING':
2185 return {
2186 ...state,
2187 [action.lockName]: true
2188 };
2189 case 'UNLOCK_POST_SAVING':
2190 {
2191 const {
2192 [action.lockName]: removedLockName,
2193 ...restState
2194 } = state;
2195 return restState;
2196 }
2197 }
2198 return state;
2199 }
2200
2201 /**
2202 * Post autosaving lock.
2203 *
2204 * When post autosaving is locked, the post will not autosave.
2205 *
2206 * @param {PostLockState} state Current state.
2207 * @param {Object} action Dispatched action.
2208 *
2209 * @return {PostLockState} Updated state.
2210 */
2211 function postAutosavingLock(state = {}, action) {
2212 switch (action.type) {
2213 case 'LOCK_POST_AUTOSAVING':
2214 return {
2215 ...state,
2216 [action.lockName]: true
2217 };
2218 case 'UNLOCK_POST_AUTOSAVING':
2219 {
2220 const {
2221 [action.lockName]: removedLockName,
2222 ...restState
2223 } = state;
2224 return restState;
2225 }
2226 }
2227 return state;
2228 }
2229
2230 /**
2231 * Reducer returning the post editor setting.
2232 *
2233 * @param {Object} state Current state.
2234 * @param {Object} action Dispatched action.
2235 *
2236 * @return {Object} Updated state.
2237 */
2238 function editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) {
2239 switch (action.type) {
2240 case 'UPDATE_EDITOR_SETTINGS':
2241 return {
2242 ...state,
2243 ...action.settings
2244 };
2245 }
2246 return state;
2247 }
2248 function renderingMode(state = 'post-only', action) {
2249 switch (action.type) {
2250 case 'SET_RENDERING_MODE':
2251 return action.mode;
2252 }
2253 return state;
2254 }
2255
2256 /**
2257 * Reducer returning the editing canvas device type.
2258 *
2259 * @param {Object} state Current state.
2260 * @param {Object} action Dispatched action.
2261 *
2262 * @return {Object} Updated state.
2263 */
2264 function deviceType(state = 'Desktop', action) {
2265 switch (action.type) {
2266 case 'SET_DEVICE_TYPE':
2267 return action.deviceType;
2268 }
2269 return state;
2270 }
2271
2272 /**
2273 * Reducer storing the list of all programmatically removed panels.
2274 *
2275 * @param {Array} state Current state.
2276 * @param {Object} action Action object.
2277 *
2278 * @return {Array} Updated state.
2279 */
2280 function removedPanels(state = [], action) {
2281 switch (action.type) {
2282 case 'REMOVE_PANEL':
2283 if (!state.includes(action.panelName)) {
2284 return [...state, action.panelName];
2285 }
2286 }
2287 return state;
2288 }
2289
2290 /**
2291 * Reducer to set the block inserter panel open or closed.
2292 *
2293 * Note: this reducer interacts with the list view panel reducer
2294 * to make sure that only one of the two panels is open at the same time.
2295 *
2296 * @param {Object} state Current state.
2297 * @param {Object} action Dispatched action.
2298 */
2299 function blockInserterPanel(state = false, action) {
2300 switch (action.type) {
2301 case 'SET_IS_LIST_VIEW_OPENED':
2302 return action.isOpen ? false : state;
2303 case 'SET_IS_INSERTER_OPENED':
2304 return action.value;
2305 }
2306 return state;
2307 }
2308
2309 /**
2310 * Reducer to set the list view panel open or closed.
2311 *
2312 * Note: this reducer interacts with the inserter panel reducer
2313 * to make sure that only one of the two panels is open at the same time.
2314 *
2315 * @param {Object} state Current state.
2316 * @param {Object} action Dispatched action.
2317 */
2318 function listViewPanel(state = false, action) {
2319 switch (action.type) {
2320 case 'SET_IS_INSERTER_OPENED':
2321 return action.value ? false : state;
2322 case 'SET_IS_LIST_VIEW_OPENED':
2323 return action.isOpen;
2324 }
2325 return state;
2326 }
2327
2328 /**
2329 * This reducer does nothing aside initializing a ref to the list view toggle.
2330 * We will have a unique ref per "editor" instance.
2331 *
2332 * @param {Object} state
2333 * @return {Object} Reference to the list view toggle button.
2334 */
2335 function listViewToggleRef(state = {
2336 current: null
2337 }) {
2338 return state;
2339 }
2340
2341 /**
2342 * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.
2343 * We will have a unique ref per "editor" instance.
2344 *
2345 * @param {Object} state
2346 * @return {Object} Reference to the inserter sidebar toggle button.
2347 */
2348 function inserterSidebarToggleRef(state = {
2349 current: null
2350 }) {
2351 return state;
2352 }
2353 function publishSidebarActive(state = false, action) {
2354 switch (action.type) {
2355 case 'OPEN_PUBLISH_SIDEBAR':
2356 return true;
2357 case 'CLOSE_PUBLISH_SIDEBAR':
2358 return false;
2359 case 'TOGGLE_PUBLISH_SIDEBAR':
2360 return !state;
2361 }
2362 return state;
2363 }
2364 /* harmony default export */ const store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2365 postId,
2366 postType,
2367 templateId,
2368 saving,
2369 deleting,
2370 postLock,
2371 template,
2372 postSavingLock,
2373 editorSettings,
2374 postAutosavingLock,
2375 renderingMode,
2376 deviceType,
2377 removedPanels,
2378 blockInserterPanel,
2379 inserterSidebarToggleRef,
2380 listViewPanel,
2381 listViewToggleRef,
2382 publishSidebarActive,
2383 dataviews: reducer
2384 }));
2385
2386 ;// external ["wp","blocks"]
2387 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
2388 ;// external ["wp","date"]
2389 const external_wp_date_namespaceObject = window["wp"]["date"];
2390 ;// external ["wp","url"]
2391 const external_wp_url_namespaceObject = window["wp"]["url"];
2392 ;// external ["wp","deprecated"]
2393 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
2394 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
2395 ;// external ["wp","primitives"]
2396 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
2397 ;// external "ReactJSXRuntime"
2398 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
2399 ;// ./packages/icons/build-module/library/layout.js
2400 /**
2401 * WordPress dependencies
2402 */
2403
2404
2405 const layout = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2406 xmlns: "http://www.w3.org/2000/svg",
2407 viewBox: "0 0 24 24",
2408 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2409 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"
2410 })
2411 });
2412 /* harmony default export */ const library_layout = (layout);
2413
2414 ;// external ["wp","preferences"]
2415 const external_wp_preferences_namespaceObject = window["wp"]["preferences"];
2416 ;// ./packages/editor/build-module/store/constants.js
2417 /* wp:polyfill */
2418 /**
2419 * Set of post properties for which edits should assume a merging behavior,
2420 * assuming an object value.
2421 *
2422 * @type {Set}
2423 */
2424 const EDIT_MERGE_PROPERTIES = new Set(['meta']);
2425
2426 /**
2427 * Constant for the store module (or reducer) key.
2428 *
2429 * @type {string}
2430 */
2431 const STORE_NAME = 'core/editor';
2432 const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID';
2433 const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID';
2434 const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
2435 const ONE_MINUTE_IN_MS = 60 * 1000;
2436 const AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content'];
2437 const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';
2438 const constants_TEMPLATE_POST_TYPE = 'wp_template';
2439 const constants_TEMPLATE_PART_POST_TYPE = 'wp_template_part';
2440 const PATTERN_POST_TYPE = 'wp_block';
2441 const NAVIGATION_POST_TYPE = 'wp_navigation';
2442 const constants_TEMPLATE_ORIGINS = {
2443 custom: 'custom',
2444 theme: 'theme',
2445 plugin: 'plugin'
2446 };
2447 const TEMPLATE_POST_TYPES = ['wp_template', 'wp_template_part'];
2448 const GLOBAL_POST_TYPES = [...TEMPLATE_POST_TYPES, 'wp_block', 'wp_navigation'];
2449
2450 ;// ./packages/icons/build-module/library/header.js
2451 /**
2452 * WordPress dependencies
2453 */
2454
2455
2456 const header = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2457 xmlns: "http://www.w3.org/2000/svg",
2458 viewBox: "0 0 24 24",
2459 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2460 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"
2461 })
2462 });
2463 /* harmony default export */ const library_header = (header);
2464
2465 ;// ./packages/icons/build-module/library/footer.js
2466 /**
2467 * WordPress dependencies
2468 */
2469
2470
2471 const footer = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2472 xmlns: "http://www.w3.org/2000/svg",
2473 viewBox: "0 0 24 24",
2474 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2475 fillRule: "evenodd",
2476 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"
2477 })
2478 });
2479 /* harmony default export */ const library_footer = (footer);
2480
2481 ;// ./packages/icons/build-module/library/sidebar.js
2482 /**
2483 * WordPress dependencies
2484 */
2485
2486
2487 const sidebar = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2488 xmlns: "http://www.w3.org/2000/svg",
2489 viewBox: "0 0 24 24",
2490 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2491 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"
2492 })
2493 });
2494 /* harmony default export */ const library_sidebar = (sidebar);
2495
2496 ;// ./packages/icons/build-module/library/symbol-filled.js
2497 /**
2498 * WordPress dependencies
2499 */
2500
2501
2502 const symbolFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2503 xmlns: "http://www.w3.org/2000/svg",
2504 viewBox: "0 0 24 24",
2505 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2506 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"
2507 })
2508 });
2509 /* harmony default export */ const symbol_filled = (symbolFilled);
2510
2511 ;// ./packages/editor/build-module/utils/get-template-part-icon.js
2512 /**
2513 * WordPress dependencies
2514 */
2515
2516 /**
2517 * Helper function to retrieve the corresponding icon by name.
2518 *
2519 * @param {string} iconName The name of the icon.
2520 *
2521 * @return {Object} The corresponding icon.
2522 */
2523 function getTemplatePartIcon(iconName) {
2524 if ('header' === iconName) {
2525 return library_header;
2526 } else if ('footer' === iconName) {
2527 return library_footer;
2528 } else if ('sidebar' === iconName) {
2529 return library_sidebar;
2530 }
2531 return symbol_filled;
2532 }
2533
2534 ;// external ["wp","privateApis"]
2535 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
2536 ;// ./packages/editor/build-module/lock-unlock.js
2537 /**
2538 * WordPress dependencies
2539 */
2540
2541 const {
2542 lock,
2543 unlock
2544 } = (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');
2545
2546 ;// ./packages/editor/build-module/store/selectors.js
2547 /**
2548 * WordPress dependencies
2549 */
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561 /**
2562 * Internal dependencies
2563 */
2564
2565
2566
2567
2568
2569 /**
2570 * Shared reference to an empty object for cases where it is important to avoid
2571 * returning a new object reference on every invocation, as in a connected or
2572 * other pure component which performs `shouldComponentUpdate` check on props.
2573 * This should be used as a last resort, since the normalized data should be
2574 * maintained by the reducer result in state.
2575 */
2576 const EMPTY_OBJECT = {};
2577
2578 /**
2579 * Returns true if any past editor history snapshots exist, or false otherwise.
2580 *
2581 * @param {Object} state Global application state.
2582 *
2583 * @return {boolean} Whether undo history exists.
2584 */
2585 const hasEditorUndo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2586 return select(external_wp_coreData_namespaceObject.store).hasUndo();
2587 });
2588
2589 /**
2590 * Returns true if any future editor history snapshots exist, or false
2591 * otherwise.
2592 *
2593 * @param {Object} state Global application state.
2594 *
2595 * @return {boolean} Whether redo history exists.
2596 */
2597 const hasEditorRedo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2598 return select(external_wp_coreData_namespaceObject.store).hasRedo();
2599 });
2600
2601 /**
2602 * Returns true if the currently edited post is yet to be saved, or false if
2603 * the post has been saved.
2604 *
2605 * @param {Object} state Global application state.
2606 *
2607 * @return {boolean} Whether the post is new.
2608 */
2609 function isEditedPostNew(state) {
2610 return getCurrentPost(state).status === 'auto-draft';
2611 }
2612
2613 /**
2614 * Returns true if content includes unsaved changes, or false otherwise.
2615 *
2616 * @param {Object} state Editor state.
2617 *
2618 * @return {boolean} Whether content includes unsaved changes.
2619 */
2620 function hasChangedContent(state) {
2621 const edits = getPostEdits(state);
2622 return 'content' in edits;
2623 }
2624
2625 /**
2626 * Returns true if there are unsaved values for the current edit session, or
2627 * false if the editing state matches the saved or new post.
2628 *
2629 * @param {Object} state Global application state.
2630 *
2631 * @return {boolean} Whether unsaved values exist.
2632 */
2633 const isEditedPostDirty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2634 // Edits should contain only fields which differ from the saved post (reset
2635 // at initial load and save complete). Thus, a non-empty edits state can be
2636 // inferred to contain unsaved values.
2637 const postType = getCurrentPostType(state);
2638 const postId = getCurrentPostId(state);
2639 return select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('postType', postType, postId);
2640 });
2641
2642 /**
2643 * Returns true if there are unsaved edits for entities other than
2644 * the editor's post, and false otherwise.
2645 *
2646 * @param {Object} state Global application state.
2647 *
2648 * @return {boolean} Whether there are edits or not.
2649 */
2650 const hasNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2651 const dirtyEntityRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords();
2652 const {
2653 type,
2654 id
2655 } = getCurrentPost(state);
2656 return dirtyEntityRecords.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
2657 });
2658
2659 /**
2660 * Returns true if there are no unsaved values for the current edit session and
2661 * if the currently edited post is new (has never been saved before).
2662 *
2663 * @param {Object} state Global application state.
2664 *
2665 * @return {boolean} Whether new post and unsaved values exist.
2666 */
2667 function isCleanNewPost(state) {
2668 return !isEditedPostDirty(state) && isEditedPostNew(state);
2669 }
2670
2671 /**
2672 * Returns the post currently being edited in its last known saved state, not
2673 * including unsaved edits. Returns an object containing relevant default post
2674 * values if the post has not yet been saved.
2675 *
2676 * @param {Object} state Global application state.
2677 *
2678 * @return {Object} Post object.
2679 */
2680 const getCurrentPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2681 const postId = getCurrentPostId(state);
2682 const postType = getCurrentPostType(state);
2683 const post = select(external_wp_coreData_namespaceObject.store).getRawEntityRecord('postType', postType, postId);
2684 if (post) {
2685 return post;
2686 }
2687
2688 // This exists for compatibility with the previous selector behavior
2689 // which would guarantee an object return based on the editor reducer's
2690 // default empty object state.
2691 return EMPTY_OBJECT;
2692 });
2693
2694 /**
2695 * Returns the post type of the post currently being edited.
2696 *
2697 * @param {Object} state Global application state.
2698 *
2699 * @example
2700 *
2701 *```js
2702 * const currentPostType = wp.data.select( 'core/editor' ).getCurrentPostType();
2703 *```
2704 * @return {string} Post type.
2705 */
2706 function getCurrentPostType(state) {
2707 return state.postType;
2708 }
2709
2710 /**
2711 * Returns the ID of the post currently being edited, or null if the post has
2712 * not yet been saved.
2713 *
2714 * @param {Object} state Global application state.
2715 *
2716 * @return {?number} ID of current post.
2717 */
2718 function getCurrentPostId(state) {
2719 return state.postId;
2720 }
2721
2722 /**
2723 * Returns the template ID currently being rendered/edited
2724 *
2725 * @param {Object} state Global application state.
2726 *
2727 * @return {string?} Template ID.
2728 */
2729 function getCurrentTemplateId(state) {
2730 return state.templateId;
2731 }
2732
2733 /**
2734 * Returns the number of revisions of the post currently being edited.
2735 *
2736 * @param {Object} state Global application state.
2737 *
2738 * @return {number} Number of revisions.
2739 */
2740 function getCurrentPostRevisionsCount(state) {
2741 var _getCurrentPost$_link;
2742 return (_getCurrentPost$_link = getCurrentPost(state)._links?.['version-history']?.[0]?.count) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : 0;
2743 }
2744
2745 /**
2746 * Returns the last revision ID of the post currently being edited,
2747 * or null if the post has no revisions.
2748 *
2749 * @param {Object} state Global application state.
2750 *
2751 * @return {?number} ID of the last revision.
2752 */
2753 function getCurrentPostLastRevisionId(state) {
2754 var _getCurrentPost$_link2;
2755 return (_getCurrentPost$_link2 = getCurrentPost(state)._links?.['predecessor-version']?.[0]?.id) !== null && _getCurrentPost$_link2 !== void 0 ? _getCurrentPost$_link2 : null;
2756 }
2757
2758 /**
2759 * Returns any post values which have been changed in the editor but not yet
2760 * been saved.
2761 *
2762 * @param {Object} state Global application state.
2763 *
2764 * @return {Object} Object of key value pairs comprising unsaved edits.
2765 */
2766 const getPostEdits = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2767 const postType = getCurrentPostType(state);
2768 const postId = getCurrentPostId(state);
2769 return select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('postType', postType, postId) || EMPTY_OBJECT;
2770 });
2771
2772 /**
2773 * Returns an attribute value of the saved post.
2774 *
2775 * @param {Object} state Global application state.
2776 * @param {string} attributeName Post attribute name.
2777 *
2778 * @return {*} Post attribute value.
2779 */
2780 function getCurrentPostAttribute(state, attributeName) {
2781 switch (attributeName) {
2782 case 'type':
2783 return getCurrentPostType(state);
2784 case 'id':
2785 return getCurrentPostId(state);
2786 default:
2787 const post = getCurrentPost(state);
2788 if (!post.hasOwnProperty(attributeName)) {
2789 break;
2790 }
2791 return getPostRawValue(post[attributeName]);
2792 }
2793 }
2794
2795 /**
2796 * Returns a single attribute of the post being edited, preferring the unsaved
2797 * edit if one exists, but merging with the attribute value for the last known
2798 * saved state of the post (this is needed for some nested attributes like meta).
2799 *
2800 * @param {Object} state Global application state.
2801 * @param {string} attributeName Post attribute name.
2802 *
2803 * @return {*} Post attribute value.
2804 */
2805 const getNestedEditedPostProperty = (0,external_wp_data_namespaceObject.createSelector)((state, attributeName) => {
2806 const edits = getPostEdits(state);
2807 if (!edits.hasOwnProperty(attributeName)) {
2808 return getCurrentPostAttribute(state, attributeName);
2809 }
2810 return {
2811 ...getCurrentPostAttribute(state, attributeName),
2812 ...edits[attributeName]
2813 };
2814 }, (state, attributeName) => [getCurrentPostAttribute(state, attributeName), getPostEdits(state)[attributeName]]);
2815
2816 /**
2817 * Returns a single attribute of the post being edited, preferring the unsaved
2818 * edit if one exists, but falling back to the attribute for the last known
2819 * saved state of the post.
2820 *
2821 * @param {Object} state Global application state.
2822 * @param {string} attributeName Post attribute name.
2823 *
2824 * @example
2825 *
2826 *```js
2827 * // Get specific media size based on the featured media ID
2828 * // Note: change sizes?.large for any registered size
2829 * const getFeaturedMediaUrl = useSelect( ( select ) => {
2830 * const getFeaturedMediaId =
2831 * select( 'core/editor' ).getEditedPostAttribute( 'featured_media' );
2832 * const getMedia = select( 'core' ).getMedia( getFeaturedMediaId );
2833 *
2834 * return (
2835 * getMedia?.media_details?.sizes?.large?.source_url || getMedia?.source_url || ''
2836 * );
2837 * }, [] );
2838 *```
2839 *
2840 * @return {*} Post attribute value.
2841 */
2842 function getEditedPostAttribute(state, attributeName) {
2843 // Special cases.
2844 switch (attributeName) {
2845 case 'content':
2846 return getEditedPostContent(state);
2847 }
2848
2849 // Fall back to saved post value if not edited.
2850 const edits = getPostEdits(state);
2851 if (!edits.hasOwnProperty(attributeName)) {
2852 return getCurrentPostAttribute(state, attributeName);
2853 }
2854
2855 // Merge properties are objects which contain only the patch edit in state,
2856 // and thus must be merged with the current post attribute.
2857 if (EDIT_MERGE_PROPERTIES.has(attributeName)) {
2858 return getNestedEditedPostProperty(state, attributeName);
2859 }
2860 return edits[attributeName];
2861 }
2862
2863 /**
2864 * Returns an attribute value of the current autosave revision for a post, or
2865 * null if there is no autosave for the post.
2866 *
2867 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector
2868 * from the '@wordpress/core-data' package and access properties on the returned
2869 * autosave object using getPostRawValue.
2870 *
2871 * @param {Object} state Global application state.
2872 * @param {string} attributeName Autosave attribute name.
2873 *
2874 * @return {*} Autosave attribute value.
2875 */
2876 const getAutosaveAttribute = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, attributeName) => {
2877 if (!AUTOSAVE_PROPERTIES.includes(attributeName) && attributeName !== 'preview_link') {
2878 return;
2879 }
2880 const postType = getCurrentPostType(state);
2881
2882 // Currently template autosaving is not supported.
2883 if (postType === 'wp_template') {
2884 return false;
2885 }
2886 const postId = getCurrentPostId(state);
2887 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
2888 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
2889 if (autosave) {
2890 return getPostRawValue(autosave[attributeName]);
2891 }
2892 });
2893
2894 /**
2895 * Returns the current visibility of the post being edited, preferring the
2896 * unsaved value if different than the saved post. The return value is one of
2897 * "private", "password", or "public".
2898 *
2899 * @param {Object} state Global application state.
2900 *
2901 * @return {string} Post visibility.
2902 */
2903 function getEditedPostVisibility(state) {
2904 const status = getEditedPostAttribute(state, 'status');
2905 if (status === 'private') {
2906 return 'private';
2907 }
2908 const password = getEditedPostAttribute(state, 'password');
2909 if (password) {
2910 return 'password';
2911 }
2912 return 'public';
2913 }
2914
2915 /**
2916 * Returns true if post is pending review.
2917 *
2918 * @param {Object} state Global application state.
2919 *
2920 * @return {boolean} Whether current post is pending review.
2921 */
2922 function isCurrentPostPending(state) {
2923 return getCurrentPost(state).status === 'pending';
2924 }
2925
2926 /**
2927 * Return true if the current post has already been published.
2928 *
2929 * @param {Object} state Global application state.
2930 * @param {Object?} currentPost Explicit current post for bypassing registry selector.
2931 *
2932 * @return {boolean} Whether the post has been published.
2933 */
2934 function isCurrentPostPublished(state, currentPost) {
2935 const post = currentPost || getCurrentPost(state);
2936 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));
2937 }
2938
2939 /**
2940 * Returns true if post is already scheduled.
2941 *
2942 * @param {Object} state Global application state.
2943 *
2944 * @return {boolean} Whether current post is scheduled to be posted.
2945 */
2946 function isCurrentPostScheduled(state) {
2947 return getCurrentPost(state).status === 'future' && !isCurrentPostPublished(state);
2948 }
2949
2950 /**
2951 * Return true if the post being edited can be published.
2952 *
2953 * @param {Object} state Global application state.
2954 *
2955 * @return {boolean} Whether the post can been published.
2956 */
2957 function isEditedPostPublishable(state) {
2958 const post = getCurrentPost(state);
2959
2960 // TODO: Post being publishable should be superset of condition of post
2961 // being saveable. Currently this restriction is imposed at UI.
2962 //
2963 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`).
2964
2965 return isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1;
2966 }
2967
2968 /**
2969 * Returns true if the post can be saved, or false otherwise. A post must
2970 * contain a title, an excerpt, or non-empty content to be valid for save.
2971 *
2972 * @param {Object} state Global application state.
2973 *
2974 * @return {boolean} Whether the post can be saved.
2975 */
2976 function isEditedPostSaveable(state) {
2977 if (isSavingPost(state)) {
2978 return false;
2979 }
2980
2981 // TODO: Post should not be saveable if not dirty. Cannot be added here at
2982 // this time since posts where meta boxes are present can be saved even if
2983 // the post is not dirty. Currently this restriction is imposed at UI, but
2984 // should be moved here.
2985 //
2986 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition)
2987 // See: <PostSavedState /> (`forceIsDirty` prop)
2988 // See: <PostPublishButton /> (`forceIsDirty` prop)
2989 // See: https://github.com/WordPress/gutenberg/pull/4184.
2990
2991 return !!getEditedPostAttribute(state, 'title') || !!getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state) || external_wp_element_namespaceObject.Platform.OS === 'native';
2992 }
2993
2994 /**
2995 * Returns true if the edited post has content. A post has content if it has at
2996 * least one saveable block or otherwise has a non-empty content property
2997 * assigned.
2998 *
2999 * @param {Object} state Global application state.
3000 *
3001 * @return {boolean} Whether post has content.
3002 */
3003 const isEditedPostEmpty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3004 // While the condition of truthy content string is sufficient to determine
3005 // emptiness, testing saveable blocks length is a trivial operation. Since
3006 // this function can be called frequently, optimize for the fast case as a
3007 // condition of the mere existence of blocks. Note that the value of edited
3008 // content takes precedent over block content, and must fall through to the
3009 // default logic.
3010 const postId = getCurrentPostId(state);
3011 const postType = getCurrentPostType(state);
3012 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
3013 if (typeof record.content !== 'function') {
3014 return !record.content;
3015 }
3016 const blocks = getEditedPostAttribute(state, 'blocks');
3017 if (blocks.length === 0) {
3018 return true;
3019 }
3020
3021 // Pierce the abstraction of the serializer in knowing that blocks are
3022 // joined with newlines such that even if every individual block
3023 // produces an empty save result, the serialized content is non-empty.
3024 if (blocks.length > 1) {
3025 return false;
3026 }
3027
3028 // There are two conditions under which the optimization cannot be
3029 // assumed, and a fallthrough to getEditedPostContent must occur:
3030 //
3031 // 1. getBlocksForSerialization has special treatment in omitting a
3032 // single unmodified default block.
3033 // 2. Comment delimiters are omitted for a freeform or unregistered
3034 // block in its serialization. The freeform block specifically may
3035 // produce an empty string in its saved output.
3036 //
3037 // For all other content, the single block is assumed to make a post
3038 // non-empty, if only by virtue of its own comment delimiters.
3039 const blockName = blocks[0].name;
3040 if (blockName !== (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() && blockName !== (0,external_wp_blocks_namespaceObject.getFreeformContentHandlerName)()) {
3041 return false;
3042 }
3043 return !getEditedPostContent(state);
3044 });
3045
3046 /**
3047 * Returns true if the post can be autosaved, or false otherwise.
3048 *
3049 * @param {Object} state Global application state.
3050 * @param {Object} autosave A raw autosave object from the REST API.
3051 *
3052 * @return {boolean} Whether the post can be autosaved.
3053 */
3054 const isEditedPostAutosaveable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3055 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving.
3056 if (!isEditedPostSaveable(state)) {
3057 return false;
3058 }
3059
3060 // A post is not autosavable when there is a post autosave lock.
3061 if (isPostAutosavingLocked(state)) {
3062 return false;
3063 }
3064 const postType = getCurrentPostType(state);
3065
3066 // Currently template autosaving is not supported.
3067 if (postType === 'wp_template') {
3068 return false;
3069 }
3070 const postId = getCurrentPostId(state);
3071 const hasFetchedAutosave = select(external_wp_coreData_namespaceObject.store).hasFetchedAutosaves(postType, postId);
3072 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
3073
3074 // Disable reason - this line causes the side-effect of fetching the autosave
3075 // via a resolver, moving below the return would result in the autosave never
3076 // being fetched.
3077 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
3078 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
3079
3080 // If any existing autosaves have not yet been fetched, this function is
3081 // unable to determine if the post is autosaveable, so return false.
3082 if (!hasFetchedAutosave) {
3083 return false;
3084 }
3085
3086 // If we don't already have an autosave, the post is autosaveable.
3087 if (!autosave) {
3088 return true;
3089 }
3090
3091 // To avoid an expensive content serialization, use the content dirtiness
3092 // flag in place of content field comparison against the known autosave.
3093 // This is not strictly accurate, and relies on a tolerance toward autosave
3094 // request failures for unnecessary saves.
3095 if (hasChangedContent(state)) {
3096 return true;
3097 }
3098
3099 // If title, excerpt, or meta have changed, the post is autosaveable.
3100 return ['title', 'excerpt', 'meta'].some(field => getPostRawValue(autosave[field]) !== getEditedPostAttribute(state, field));
3101 });
3102
3103 /**
3104 * Return true if the post being edited is being scheduled. Preferring the
3105 * unsaved status values.
3106 *
3107 * @param {Object} state Global application state.
3108 *
3109 * @return {boolean} Whether the post has been published.
3110 */
3111 function isEditedPostBeingScheduled(state) {
3112 const date = getEditedPostAttribute(state, 'date');
3113 // Offset the date by one minute (network latency).
3114 const checkedDate = new Date(Number((0,external_wp_date_namespaceObject.getDate)(date)) - ONE_MINUTE_IN_MS);
3115 return (0,external_wp_date_namespaceObject.isInTheFuture)(checkedDate);
3116 }
3117
3118 /**
3119 * Returns whether the current post should be considered to have a "floating"
3120 * date (i.e. that it would publish "Immediately" rather than at a set time).
3121 *
3122 * Unlike in the PHP backend, the REST API returns a full date string for posts
3123 * where the 0000-00-00T00:00:00 placeholder is present in the database. To
3124 * infer that a post is set to publish "Immediately" we check whether the date
3125 * and modified date are the same.
3126 *
3127 * @param {Object} state Editor state.
3128 *
3129 * @return {boolean} Whether the edited post has a floating date value.
3130 */
3131 function isEditedPostDateFloating(state) {
3132 const date = getEditedPostAttribute(state, 'date');
3133 const modified = getEditedPostAttribute(state, 'modified');
3134
3135 // This should be the status of the persisted post
3136 // It shouldn't use the "edited" status otherwise it breaks the
3137 // inferred post data floating status
3138 // See https://github.com/WordPress/gutenberg/issues/28083.
3139 const status = getCurrentPost(state).status;
3140 if (status === 'draft' || status === 'auto-draft' || status === 'pending') {
3141 return date === modified || date === null;
3142 }
3143 return false;
3144 }
3145
3146 /**
3147 * Returns true if the post is currently being deleted, or false otherwise.
3148 *
3149 * @param {Object} state Editor state.
3150 *
3151 * @return {boolean} Whether post is being deleted.
3152 */
3153 function isDeletingPost(state) {
3154 return !!state.deleting.pending;
3155 }
3156
3157 /**
3158 * Returns true if the post is currently being saved, or false otherwise.
3159 *
3160 * @param {Object} state Global application state.
3161 *
3162 * @return {boolean} Whether post is being saved.
3163 */
3164 function isSavingPost(state) {
3165 return !!state.saving.pending;
3166 }
3167
3168 /**
3169 * Returns true if non-post entities are currently being saved, or false otherwise.
3170 *
3171 * @param {Object} state Global application state.
3172 *
3173 * @return {boolean} Whether non-post entities are being saved.
3174 */
3175 const isSavingNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3176 const entitiesBeingSaved = select(external_wp_coreData_namespaceObject.store).__experimentalGetEntitiesBeingSaved();
3177 const {
3178 type,
3179 id
3180 } = getCurrentPost(state);
3181 return entitiesBeingSaved.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
3182 });
3183
3184 /**
3185 * Returns true if a previous post save was attempted successfully, or false
3186 * otherwise.
3187 *
3188 * @param {Object} state Global application state.
3189 *
3190 * @return {boolean} Whether the post was saved successfully.
3191 */
3192 const didPostSaveRequestSucceed = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3193 const postType = getCurrentPostType(state);
3194 const postId = getCurrentPostId(state);
3195 return !select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3196 });
3197
3198 /**
3199 * Returns true if a previous post save was attempted but failed, or false
3200 * otherwise.
3201 *
3202 * @param {Object} state Global application state.
3203 *
3204 * @return {boolean} Whether the post save failed.
3205 */
3206 const didPostSaveRequestFail = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3207 const postType = getCurrentPostType(state);
3208 const postId = getCurrentPostId(state);
3209 return !!select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3210 });
3211
3212 /**
3213 * Returns true if the post is autosaving, or false otherwise.
3214 *
3215 * @param {Object} state Global application state.
3216 *
3217 * @return {boolean} Whether the post is autosaving.
3218 */
3219 function isAutosavingPost(state) {
3220 return isSavingPost(state) && Boolean(state.saving.options?.isAutosave);
3221 }
3222
3223 /**
3224 * Returns true if the post is being previewed, or false otherwise.
3225 *
3226 * @param {Object} state Global application state.
3227 *
3228 * @return {boolean} Whether the post is being previewed.
3229 */
3230 function isPreviewingPost(state) {
3231 return isSavingPost(state) && Boolean(state.saving.options?.isPreview);
3232 }
3233
3234 /**
3235 * Returns the post preview link
3236 *
3237 * @param {Object} state Global application state.
3238 *
3239 * @return {string | undefined} Preview Link.
3240 */
3241 function getEditedPostPreviewLink(state) {
3242 if (state.saving.pending || isSavingPost(state)) {
3243 return;
3244 }
3245 let previewLink = getAutosaveAttribute(state, 'preview_link');
3246 // Fix for issue: https://github.com/WordPress/gutenberg/issues/33616
3247 // If the post is draft, ignore the preview link from the autosave record,
3248 // because the preview could be a stale autosave if the post was switched from
3249 // published to draft.
3250 // See: https://github.com/WordPress/gutenberg/pull/37952.
3251 if (!previewLink || 'draft' === getCurrentPost(state).status) {
3252 previewLink = getEditedPostAttribute(state, 'link');
3253 if (previewLink) {
3254 previewLink = (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3255 preview: true
3256 });
3257 }
3258 }
3259 const featuredImageId = getEditedPostAttribute(state, 'featured_media');
3260 if (previewLink && featuredImageId) {
3261 return (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3262 _thumbnail_id: featuredImageId
3263 });
3264 }
3265 return previewLink;
3266 }
3267
3268 /**
3269 * Returns a suggested post format for the current post, inferred only if there
3270 * is a single block within the post and it is of a type known to match a
3271 * default post format. Returns null if the format cannot be determined.
3272 *
3273 * @return {?string} Suggested post format.
3274 */
3275 const getSuggestedPostFormat = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3276 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocks();
3277 if (blocks.length > 2) {
3278 return null;
3279 }
3280 let name;
3281 // If there is only one block in the content of the post grab its name
3282 // so we can derive a suitable post format from it.
3283 if (blocks.length === 1) {
3284 name = blocks[0].name;
3285 // Check for core/embed `video` and `audio` eligible suggestions.
3286 if (name === 'core/embed') {
3287 const provider = blocks[0].attributes?.providerNameSlug;
3288 if (['youtube', 'vimeo'].includes(provider)) {
3289 name = 'core/video';
3290 } else if (['spotify', 'soundcloud'].includes(provider)) {
3291 name = 'core/audio';
3292 }
3293 }
3294 }
3295
3296 // If there are two blocks in the content and the last one is a text blocks
3297 // grab the name of the first one to also suggest a post format from it.
3298 if (blocks.length === 2 && blocks[1].name === 'core/paragraph') {
3299 name = blocks[0].name;
3300 }
3301
3302 // We only convert to default post formats in core.
3303 switch (name) {
3304 case 'core/image':
3305 return 'image';
3306 case 'core/quote':
3307 case 'core/pullquote':
3308 return 'quote';
3309 case 'core/gallery':
3310 return 'gallery';
3311 case 'core/video':
3312 return 'video';
3313 case 'core/audio':
3314 return 'audio';
3315 default:
3316 return null;
3317 }
3318 });
3319
3320 /**
3321 * Returns the content of the post being edited.
3322 *
3323 * @param {Object} state Global application state.
3324 *
3325 * @return {string} Post content.
3326 */
3327 const getEditedPostContent = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3328 const postId = getCurrentPostId(state);
3329 const postType = getCurrentPostType(state);
3330 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
3331 if (record) {
3332 if (typeof record.content === 'function') {
3333 return record.content(record);
3334 } else if (record.blocks) {
3335 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
3336 } else if (record.content) {
3337 return record.content;
3338 }
3339 }
3340 return '';
3341 });
3342
3343 /**
3344 * Returns true if the post is being published, or false otherwise.
3345 *
3346 * @param {Object} state Global application state.
3347 *
3348 * @return {boolean} Whether post is being published.
3349 */
3350 function isPublishingPost(state) {
3351 return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, 'status') === 'publish';
3352 }
3353
3354 /**
3355 * Returns whether the permalink is editable or not.
3356 *
3357 * @param {Object} state Editor state.
3358 *
3359 * @return {boolean} Whether or not the permalink is editable.
3360 */
3361 function isPermalinkEditable(state) {
3362 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3363 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
3364 }
3365
3366 /**
3367 * Returns the permalink for the post.
3368 *
3369 * @param {Object} state Editor state.
3370 *
3371 * @return {?string} The permalink, or null if the post is not viewable.
3372 */
3373 function getPermalink(state) {
3374 const permalinkParts = getPermalinkParts(state);
3375 if (!permalinkParts) {
3376 return null;
3377 }
3378 const {
3379 prefix,
3380 postName,
3381 suffix
3382 } = permalinkParts;
3383 if (isPermalinkEditable(state)) {
3384 return prefix + postName + suffix;
3385 }
3386 return prefix;
3387 }
3388
3389 /**
3390 * Returns the slug for the post being edited, preferring a manually edited
3391 * value if one exists, then a sanitized version of the current post title, and
3392 * finally the post ID.
3393 *
3394 * @param {Object} state Editor state.
3395 *
3396 * @return {string} The current slug to be displayed in the editor
3397 */
3398 function getEditedPostSlug(state) {
3399 return getEditedPostAttribute(state, 'slug') || (0,external_wp_url_namespaceObject.cleanForSlug)(getEditedPostAttribute(state, 'title')) || getCurrentPostId(state);
3400 }
3401
3402 /**
3403 * Returns the permalink for a post, split into its three parts: the prefix,
3404 * the postName, and the suffix.
3405 *
3406 * @param {Object} state Editor state.
3407 *
3408 * @return {Object} An object containing the prefix, postName, and suffix for
3409 * the permalink, or null if the post is not viewable.
3410 */
3411 function getPermalinkParts(state) {
3412 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3413 if (!permalinkTemplate) {
3414 return null;
3415 }
3416 const postName = getEditedPostAttribute(state, 'slug') || getEditedPostAttribute(state, 'generated_slug');
3417 const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
3418 return {
3419 prefix,
3420 postName,
3421 suffix
3422 };
3423 }
3424
3425 /**
3426 * Returns whether the post is locked.
3427 *
3428 * @param {Object} state Global application state.
3429 *
3430 * @return {boolean} Is locked.
3431 */
3432 function isPostLocked(state) {
3433 return state.postLock.isLocked;
3434 }
3435
3436 /**
3437 * Returns whether post saving is locked.
3438 *
3439 * @param {Object} state Global application state.
3440 *
3441 * @return {boolean} Is locked.
3442 */
3443 function isPostSavingLocked(state) {
3444 return Object.keys(state.postSavingLock).length > 0;
3445 }
3446
3447 /**
3448 * Returns whether post autosaving is locked.
3449 *
3450 * @param {Object} state Global application state.
3451 *
3452 * @return {boolean} Is locked.
3453 */
3454 function isPostAutosavingLocked(state) {
3455 return Object.keys(state.postAutosavingLock).length > 0;
3456 }
3457
3458 /**
3459 * Returns whether the edition of the post has been taken over.
3460 *
3461 * @param {Object} state Global application state.
3462 *
3463 * @return {boolean} Is post lock takeover.
3464 */
3465 function isPostLockTakeover(state) {
3466 return state.postLock.isTakeover;
3467 }
3468
3469 /**
3470 * Returns details about the post lock user.
3471 *
3472 * @param {Object} state Global application state.
3473 *
3474 * @return {Object} A user object.
3475 */
3476 function getPostLockUser(state) {
3477 return state.postLock.user;
3478 }
3479
3480 /**
3481 * Returns the active post lock.
3482 *
3483 * @param {Object} state Global application state.
3484 *
3485 * @return {Object} The lock object.
3486 */
3487 function getActivePostLock(state) {
3488 return state.postLock.activePostLock;
3489 }
3490
3491 /**
3492 * Returns whether or not the user has the unfiltered_html capability.
3493 *
3494 * @param {Object} state Editor state.
3495 *
3496 * @return {boolean} Whether the user can or can't post unfiltered HTML.
3497 */
3498 function canUserUseUnfilteredHTML(state) {
3499 return Boolean(getCurrentPost(state)._links?.hasOwnProperty('wp:action-unfiltered-html'));
3500 }
3501
3502 /**
3503 * Returns whether the pre-publish panel should be shown
3504 * or skipped when the user clicks the "publish" button.
3505 *
3506 * @return {boolean} Whether the pre-publish panel should be shown or not.
3507 */
3508 const isPublishSidebarEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => !!select(external_wp_preferences_namespaceObject.store).get('core', 'isPublishSidebarEnabled'));
3509
3510 /**
3511 * Return the current block list.
3512 *
3513 * @param {Object} state
3514 * @return {Array} Block list.
3515 */
3516 const getEditorBlocks = (0,external_wp_data_namespaceObject.createSelector)(state => {
3517 return getEditedPostAttribute(state, 'blocks') || (0,external_wp_blocks_namespaceObject.parse)(getEditedPostContent(state));
3518 }, state => [getEditedPostAttribute(state, 'blocks'), getEditedPostContent(state)]);
3519
3520 /**
3521 * Returns true if the given panel was programmatically removed, or false otherwise.
3522 * All panels are not removed by default.
3523 *
3524 * @param {Object} state Global application state.
3525 * @param {string} panelName A string that identifies the panel.
3526 *
3527 * @return {boolean} Whether or not the panel is removed.
3528 */
3529 function isEditorPanelRemoved(state, panelName) {
3530 return state.removedPanels.includes(panelName);
3531 }
3532
3533 /**
3534 * Returns true if the given panel is enabled, or false otherwise. Panels are
3535 * enabled by default.
3536 *
3537 * @param {Object} state Global application state.
3538 * @param {string} panelName A string that identifies the panel.
3539 *
3540 * @return {boolean} Whether or not the panel is enabled.
3541 */
3542 const isEditorPanelEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3543 // For backward compatibility, we check edit-post
3544 // even though now this is in "editor" package.
3545 const inactivePanels = select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels');
3546 return !isEditorPanelRemoved(state, panelName) && !inactivePanels?.includes(panelName);
3547 });
3548
3549 /**
3550 * Returns true if the given panel is open, or false otherwise. Panels are
3551 * closed by default.
3552 *
3553 * @param {Object} state Global application state.
3554 * @param {string} panelName A string that identifies the panel.
3555 *
3556 * @return {boolean} Whether or not the panel is open.
3557 */
3558 const isEditorPanelOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3559 // For backward compatibility, we check edit-post
3560 // even though now this is in "editor" package.
3561 const openPanels = select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels');
3562 return !!openPanels?.includes(panelName);
3563 });
3564
3565 /**
3566 * A block selection object.
3567 *
3568 * @typedef {Object} WPBlockSelection
3569 *
3570 * @property {string} clientId A block client ID.
3571 * @property {string} attributeKey A block attribute key.
3572 * @property {number} offset An attribute value offset, based on the rich
3573 * text value. See `wp.richText.create`.
3574 */
3575
3576 /**
3577 * Returns the current selection start.
3578 *
3579 * @param {Object} state
3580 * @return {WPBlockSelection} The selection start.
3581 *
3582 * @deprecated since Gutenberg 10.0.0.
3583 */
3584 function getEditorSelectionStart(state) {
3585 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3586 since: '5.8',
3587 alternative: "select('core/editor').getEditorSelection"
3588 });
3589 return getEditedPostAttribute(state, 'selection')?.selectionStart;
3590 }
3591
3592 /**
3593 * Returns the current selection end.
3594 *
3595 * @param {Object} state
3596 * @return {WPBlockSelection} The selection end.
3597 *
3598 * @deprecated since Gutenberg 10.0.0.
3599 */
3600 function getEditorSelectionEnd(state) {
3601 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3602 since: '5.8',
3603 alternative: "select('core/editor').getEditorSelection"
3604 });
3605 return getEditedPostAttribute(state, 'selection')?.selectionEnd;
3606 }
3607
3608 /**
3609 * Returns the current selection.
3610 *
3611 * @param {Object} state
3612 * @return {WPBlockSelection} The selection end.
3613 */
3614 function getEditorSelection(state) {
3615 return getEditedPostAttribute(state, 'selection');
3616 }
3617
3618 /**
3619 * Is the editor ready
3620 *
3621 * @param {Object} state
3622 * @return {boolean} is Ready.
3623 */
3624 function __unstableIsEditorReady(state) {
3625 return !!state.postId;
3626 }
3627
3628 /**
3629 * Returns the post editor settings.
3630 *
3631 * @param {Object} state Editor state.
3632 *
3633 * @return {Object} The editor settings object.
3634 */
3635 function getEditorSettings(state) {
3636 return state.editorSettings;
3637 }
3638
3639 /**
3640 * Returns the post editor's rendering mode.
3641 *
3642 * @param {Object} state Editor state.
3643 *
3644 * @return {string} Rendering mode.
3645 */
3646 function getRenderingMode(state) {
3647 return state.renderingMode;
3648 }
3649
3650 /**
3651 * Returns the current editing canvas device type.
3652 *
3653 * @param {Object} state Global application state.
3654 *
3655 * @return {string} Device type.
3656 */
3657 const getDeviceType = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3658 const isZoomOut = unlock(select(external_wp_blockEditor_namespaceObject.store)).isZoomOut();
3659 if (isZoomOut) {
3660 return 'Desktop';
3661 }
3662 return state.deviceType;
3663 });
3664
3665 /**
3666 * Returns true if the list view is opened.
3667 *
3668 * @param {Object} state Global application state.
3669 *
3670 * @return {boolean} Whether the list view is opened.
3671 */
3672 function isListViewOpened(state) {
3673 return state.listViewPanel;
3674 }
3675
3676 /**
3677 * Returns true if the inserter is opened.
3678 *
3679 * @param {Object} state Global application state.
3680 *
3681 * @return {boolean} Whether the inserter is opened.
3682 */
3683 function isInserterOpened(state) {
3684 return !!state.blockInserterPanel;
3685 }
3686
3687 /**
3688 * Returns the current editing mode.
3689 *
3690 * @param {Object} state Global application state.
3691 *
3692 * @return {string} Editing mode.
3693 */
3694 const getEditorMode = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3695 var _select$get;
3696 return (_select$get = select(external_wp_preferences_namespaceObject.store).get('core', 'editorMode')) !== null && _select$get !== void 0 ? _select$get : 'visual';
3697 });
3698
3699 /*
3700 * Backward compatibility
3701 */
3702
3703 /**
3704 * Returns state object prior to a specified optimist transaction ID, or `null`
3705 * if the transaction corresponding to the given ID cannot be found.
3706 *
3707 * @deprecated since Gutenberg 9.7.0.
3708 */
3709 function getStateBeforeOptimisticTransaction() {
3710 external_wp_deprecated_default()("select('core/editor').getStateBeforeOptimisticTransaction", {
3711 since: '5.7',
3712 hint: 'No state history is kept on this store anymore'
3713 });
3714 return null;
3715 }
3716 /**
3717 * Returns true if an optimistic transaction is pending commit, for which the
3718 * before state satisfies the given predicate function.
3719 *
3720 * @deprecated since Gutenberg 9.7.0.
3721 */
3722 function inSomeHistory() {
3723 external_wp_deprecated_default()("select('core/editor').inSomeHistory", {
3724 since: '5.7',
3725 hint: 'No state history is kept on this store anymore'
3726 });
3727 return false;
3728 }
3729 function getBlockEditorSelector(name) {
3730 return (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, ...args) => {
3731 external_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', {
3732 since: '5.3',
3733 alternative: "`wp.data.select( 'core/block-editor' )." + name + '`',
3734 version: '6.2'
3735 });
3736 return select(external_wp_blockEditor_namespaceObject.store)[name](...args);
3737 });
3738 }
3739
3740 /**
3741 * @see getBlockName in core/block-editor store.
3742 */
3743 const getBlockName = getBlockEditorSelector('getBlockName');
3744
3745 /**
3746 * @see isBlockValid in core/block-editor store.
3747 */
3748 const isBlockValid = getBlockEditorSelector('isBlockValid');
3749
3750 /**
3751 * @see getBlockAttributes in core/block-editor store.
3752 */
3753 const getBlockAttributes = getBlockEditorSelector('getBlockAttributes');
3754
3755 /**
3756 * @see getBlock in core/block-editor store.
3757 */
3758 const getBlock = getBlockEditorSelector('getBlock');
3759
3760 /**
3761 * @see getBlocks in core/block-editor store.
3762 */
3763 const getBlocks = getBlockEditorSelector('getBlocks');
3764
3765 /**
3766 * @see getClientIdsOfDescendants in core/block-editor store.
3767 */
3768 const getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants');
3769
3770 /**
3771 * @see getClientIdsWithDescendants in core/block-editor store.
3772 */
3773 const getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants');
3774
3775 /**
3776 * @see getGlobalBlockCount in core/block-editor store.
3777 */
3778 const getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount');
3779
3780 /**
3781 * @see getBlocksByClientId in core/block-editor store.
3782 */
3783 const getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId');
3784
3785 /**
3786 * @see getBlockCount in core/block-editor store.
3787 */
3788 const getBlockCount = getBlockEditorSelector('getBlockCount');
3789
3790 /**
3791 * @see getBlockSelectionStart in core/block-editor store.
3792 */
3793 const getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart');
3794
3795 /**
3796 * @see getBlockSelectionEnd in core/block-editor store.
3797 */
3798 const getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd');
3799
3800 /**
3801 * @see getSelectedBlockCount in core/block-editor store.
3802 */
3803 const getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount');
3804
3805 /**
3806 * @see hasSelectedBlock in core/block-editor store.
3807 */
3808 const hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock');
3809
3810 /**
3811 * @see getSelectedBlockClientId in core/block-editor store.
3812 */
3813 const getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId');
3814
3815 /**
3816 * @see getSelectedBlock in core/block-editor store.
3817 */
3818 const getSelectedBlock = getBlockEditorSelector('getSelectedBlock');
3819
3820 /**
3821 * @see getBlockRootClientId in core/block-editor store.
3822 */
3823 const getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId');
3824
3825 /**
3826 * @see getBlockHierarchyRootClientId in core/block-editor store.
3827 */
3828 const getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId');
3829
3830 /**
3831 * @see getAdjacentBlockClientId in core/block-editor store.
3832 */
3833 const getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId');
3834
3835 /**
3836 * @see getPreviousBlockClientId in core/block-editor store.
3837 */
3838 const getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId');
3839
3840 /**
3841 * @see getNextBlockClientId in core/block-editor store.
3842 */
3843 const getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId');
3844
3845 /**
3846 * @see getSelectedBlocksInitialCaretPosition in core/block-editor store.
3847 */
3848 const getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition');
3849
3850 /**
3851 * @see getMultiSelectedBlockClientIds in core/block-editor store.
3852 */
3853 const getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds');
3854
3855 /**
3856 * @see getMultiSelectedBlocks in core/block-editor store.
3857 */
3858 const getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks');
3859
3860 /**
3861 * @see getFirstMultiSelectedBlockClientId in core/block-editor store.
3862 */
3863 const getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId');
3864
3865 /**
3866 * @see getLastMultiSelectedBlockClientId in core/block-editor store.
3867 */
3868 const getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId');
3869
3870 /**
3871 * @see isFirstMultiSelectedBlock in core/block-editor store.
3872 */
3873 const isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock');
3874
3875 /**
3876 * @see isBlockMultiSelected in core/block-editor store.
3877 */
3878 const isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected');
3879
3880 /**
3881 * @see isAncestorMultiSelected in core/block-editor store.
3882 */
3883 const isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected');
3884
3885 /**
3886 * @see getMultiSelectedBlocksStartClientId in core/block-editor store.
3887 */
3888 const getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId');
3889
3890 /**
3891 * @see getMultiSelectedBlocksEndClientId in core/block-editor store.
3892 */
3893 const getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId');
3894
3895 /**
3896 * @see getBlockOrder in core/block-editor store.
3897 */
3898 const getBlockOrder = getBlockEditorSelector('getBlockOrder');
3899
3900 /**
3901 * @see getBlockIndex in core/block-editor store.
3902 */
3903 const getBlockIndex = getBlockEditorSelector('getBlockIndex');
3904
3905 /**
3906 * @see isBlockSelected in core/block-editor store.
3907 */
3908 const isBlockSelected = getBlockEditorSelector('isBlockSelected');
3909
3910 /**
3911 * @see hasSelectedInnerBlock in core/block-editor store.
3912 */
3913 const hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock');
3914
3915 /**
3916 * @see isBlockWithinSelection in core/block-editor store.
3917 */
3918 const isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection');
3919
3920 /**
3921 * @see hasMultiSelection in core/block-editor store.
3922 */
3923 const hasMultiSelection = getBlockEditorSelector('hasMultiSelection');
3924
3925 /**
3926 * @see isMultiSelecting in core/block-editor store.
3927 */
3928 const isMultiSelecting = getBlockEditorSelector('isMultiSelecting');
3929
3930 /**
3931 * @see isSelectionEnabled in core/block-editor store.
3932 */
3933 const isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled');
3934
3935 /**
3936 * @see getBlockMode in core/block-editor store.
3937 */
3938 const getBlockMode = getBlockEditorSelector('getBlockMode');
3939
3940 /**
3941 * @see isTyping in core/block-editor store.
3942 */
3943 const isTyping = getBlockEditorSelector('isTyping');
3944
3945 /**
3946 * @see isCaretWithinFormattedText in core/block-editor store.
3947 */
3948 const isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText');
3949
3950 /**
3951 * @see getBlockInsertionPoint in core/block-editor store.
3952 */
3953 const getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint');
3954
3955 /**
3956 * @see isBlockInsertionPointVisible in core/block-editor store.
3957 */
3958 const isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible');
3959
3960 /**
3961 * @see isValidTemplate in core/block-editor store.
3962 */
3963 const isValidTemplate = getBlockEditorSelector('isValidTemplate');
3964
3965 /**
3966 * @see getTemplate in core/block-editor store.
3967 */
3968 const getTemplate = getBlockEditorSelector('getTemplate');
3969
3970 /**
3971 * @see getTemplateLock in core/block-editor store.
3972 */
3973 const getTemplateLock = getBlockEditorSelector('getTemplateLock');
3974
3975 /**
3976 * @see canInsertBlockType in core/block-editor store.
3977 */
3978 const canInsertBlockType = getBlockEditorSelector('canInsertBlockType');
3979
3980 /**
3981 * @see getInserterItems in core/block-editor store.
3982 */
3983 const getInserterItems = getBlockEditorSelector('getInserterItems');
3984
3985 /**
3986 * @see hasInserterItems in core/block-editor store.
3987 */
3988 const hasInserterItems = getBlockEditorSelector('hasInserterItems');
3989
3990 /**
3991 * @see getBlockListSettings in core/block-editor store.
3992 */
3993 const getBlockListSettings = getBlockEditorSelector('getBlockListSettings');
3994
3995 /**
3996 * Returns the default template types.
3997 *
3998 * @param {Object} state Global application state.
3999 *
4000 * @return {Object} The template types.
4001 */
4002 function __experimentalGetDefaultTemplateTypes(state) {
4003 return getEditorSettings(state)?.defaultTemplateTypes;
4004 }
4005
4006 /**
4007 * Returns the default template part areas.
4008 *
4009 * @param {Object} state Global application state.
4010 *
4011 * @return {Array} The template part areas.
4012 */
4013 const __experimentalGetDefaultTemplatePartAreas = (0,external_wp_data_namespaceObject.createSelector)(state => {
4014 var _getEditorSettings$de;
4015 const areas = (_getEditorSettings$de = getEditorSettings(state)?.defaultTemplatePartAreas) !== null && _getEditorSettings$de !== void 0 ? _getEditorSettings$de : [];
4016 return areas.map(item => {
4017 return {
4018 ...item,
4019 icon: getTemplatePartIcon(item.icon)
4020 };
4021 });
4022 }, state => [getEditorSettings(state)?.defaultTemplatePartAreas]);
4023
4024 /**
4025 * Returns a default template type searched by slug.
4026 *
4027 * @param {Object} state Global application state.
4028 * @param {string} slug The template type slug.
4029 *
4030 * @return {Object} The template type.
4031 */
4032 const __experimentalGetDefaultTemplateType = (0,external_wp_data_namespaceObject.createSelector)((state, slug) => {
4033 var _Object$values$find;
4034 const templateTypes = __experimentalGetDefaultTemplateTypes(state);
4035 if (!templateTypes) {
4036 return EMPTY_OBJECT;
4037 }
4038 return (_Object$values$find = Object.values(templateTypes).find(type => type.slug === slug)) !== null && _Object$values$find !== void 0 ? _Object$values$find : EMPTY_OBJECT;
4039 }, state => [__experimentalGetDefaultTemplateTypes(state)]);
4040
4041 /**
4042 * Given a template entity, return information about it which is ready to be
4043 * rendered, such as the title, description, and icon.
4044 *
4045 * @param {Object} state Global application state.
4046 * @param {Object} template The template for which we need information.
4047 * @return {Object} Information about the template, including title, description, and icon.
4048 */
4049 const __experimentalGetTemplateInfo = (0,external_wp_data_namespaceObject.createSelector)((state, template) => {
4050 if (!template) {
4051 return EMPTY_OBJECT;
4052 }
4053 const {
4054 description,
4055 slug,
4056 title,
4057 area
4058 } = template;
4059 const {
4060 title: defaultTitle,
4061 description: defaultDescription
4062 } = __experimentalGetDefaultTemplateType(state, slug);
4063 const templateTitle = typeof title === 'string' ? title : title?.rendered;
4064 const templateDescription = typeof description === 'string' ? description : description?.raw;
4065 const templateIcon = __experimentalGetDefaultTemplatePartAreas(state).find(item => area === item.area)?.icon || library_layout;
4066 return {
4067 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
4068 description: templateDescription || defaultDescription,
4069 icon: templateIcon
4070 };
4071 }, state => [__experimentalGetDefaultTemplateTypes(state), __experimentalGetDefaultTemplatePartAreas(state)]);
4072
4073 /**
4074 * Returns a post type label depending on the current post.
4075 *
4076 * @param {Object} state Global application state.
4077 *
4078 * @return {string|undefined} The post type label if available, otherwise undefined.
4079 */
4080 const getPostTypeLabel = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
4081 const currentPostType = getCurrentPostType(state);
4082 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(currentPostType);
4083 // Disable reason: Post type labels object is shaped like this.
4084 // eslint-disable-next-line camelcase
4085 return postType?.labels?.singular_name;
4086 });
4087
4088 /**
4089 * Returns true if the publish sidebar is opened.
4090 *
4091 * @param {Object} state Global application state
4092 *
4093 * @return {boolean} Whether the publish sidebar is open.
4094 */
4095 function isPublishSidebarOpened(state) {
4096 return state.publishSidebarActive;
4097 }
4098
4099 ;// external ["wp","a11y"]
4100 const external_wp_a11y_namespaceObject = window["wp"]["a11y"];
4101 ;// external ["wp","apiFetch"]
4102 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
4103 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
4104 ;// external ["wp","notices"]
4105 const external_wp_notices_namespaceObject = window["wp"]["notices"];
4106 ;// external ["wp","i18n"]
4107 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
4108 ;// ./packages/editor/build-module/store/local-autosave.js
4109 /**
4110 * Function returning a sessionStorage key to set or retrieve a given post's
4111 * automatic session backup.
4112 *
4113 * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's
4114 * `loggedout` handler can clear sessionStorage of any user-private content.
4115 *
4116 * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103
4117 *
4118 * @param {string} postId Post ID.
4119 * @param {boolean} isPostNew Whether post new.
4120 *
4121 * @return {string} sessionStorage key
4122 */
4123 function postKey(postId, isPostNew) {
4124 return `wp-autosave-block-editor-post-${isPostNew ? 'auto-draft' : postId}`;
4125 }
4126 function localAutosaveGet(postId, isPostNew) {
4127 return window.sessionStorage.getItem(postKey(postId, isPostNew));
4128 }
4129 function localAutosaveSet(postId, isPostNew, title, content, excerpt) {
4130 window.sessionStorage.setItem(postKey(postId, isPostNew), JSON.stringify({
4131 post_title: title,
4132 content,
4133 excerpt
4134 }));
4135 }
4136 function localAutosaveClear(postId, isPostNew) {
4137 window.sessionStorage.removeItem(postKey(postId, isPostNew));
4138 }
4139
4140 ;// ./packages/editor/build-module/store/utils/notice-builder.js
4141 /**
4142 * WordPress dependencies
4143 */
4144
4145
4146 /**
4147 * Internal dependencies
4148 */
4149
4150
4151 /**
4152 * Builds the arguments for a success notification dispatch.
4153 *
4154 * @param {Object} data Incoming data to build the arguments from.
4155 *
4156 * @return {Array} Arguments for dispatch. An empty array signals no
4157 * notification should be sent.
4158 */
4159 function getNotificationArgumentsForSaveSuccess(data) {
4160 var _postType$viewable;
4161 const {
4162 previousPost,
4163 post,
4164 postType
4165 } = data;
4166 // Autosaves are neither shown a notice nor redirected.
4167 if (data.options?.isAutosave) {
4168 return [];
4169 }
4170 const publishStatus = ['publish', 'private', 'future'];
4171 const isPublished = publishStatus.includes(previousPost.status);
4172 const willPublish = publishStatus.includes(post.status);
4173 const willTrash = post.status === 'trash' && previousPost.status !== 'trash';
4174 let noticeMessage;
4175 let shouldShowLink = (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false;
4176 let isDraft;
4177
4178 // Always should a notice, which will be spoken for accessibility.
4179 if (willTrash) {
4180 noticeMessage = postType.labels.item_trashed;
4181 shouldShowLink = false;
4182 } else if (!isPublished && !willPublish) {
4183 // If saving a non-published post, don't show notice.
4184 noticeMessage = (0,external_wp_i18n_namespaceObject.__)('Draft saved.');
4185 isDraft = true;
4186 } else if (isPublished && !willPublish) {
4187 // If undoing publish status, show specific notice.
4188 noticeMessage = postType.labels.item_reverted_to_draft;
4189 shouldShowLink = false;
4190 } else if (!isPublished && willPublish) {
4191 // If publishing or scheduling a post, show the corresponding
4192 // publish message.
4193 noticeMessage = {
4194 publish: postType.labels.item_published,
4195 private: postType.labels.item_published_privately,
4196 future: postType.labels.item_scheduled
4197 }[post.status];
4198 } else {
4199 // Generic fallback notice.
4200 noticeMessage = postType.labels.item_updated;
4201 }
4202 const actions = [];
4203 if (shouldShowLink) {
4204 actions.push({
4205 label: isDraft ? (0,external_wp_i18n_namespaceObject.__)('View Preview') : postType.labels.view_item,
4206 url: post.link
4207 });
4208 }
4209 return [noticeMessage, {
4210 id: SAVE_POST_NOTICE_ID,
4211 type: 'snackbar',
4212 actions
4213 }];
4214 }
4215
4216 /**
4217 * Builds the fail notification arguments for dispatch.
4218 *
4219 * @param {Object} data Incoming data to build the arguments with.
4220 *
4221 * @return {Array} Arguments for dispatch. An empty array signals no
4222 * notification should be sent.
4223 */
4224 function getNotificationArgumentsForSaveFail(data) {
4225 const {
4226 post,
4227 edits,
4228 error
4229 } = data;
4230 if (error && 'rest_autosave_no_changes' === error.code) {
4231 // Autosave requested a new autosave, but there were no changes. This shouldn't
4232 // result in an error notice for the user.
4233 return [];
4234 }
4235 const publishStatus = ['publish', 'private', 'future'];
4236 const isPublished = publishStatus.indexOf(post.status) !== -1;
4237 // If the post was being published, we show the corresponding publish error message
4238 // Unless we publish an "updating failed" message.
4239 const messages = {
4240 publish: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4241 private: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4242 future: (0,external_wp_i18n_namespaceObject.__)('Scheduling failed.')
4243 };
4244 let noticeMessage = !isPublished && publishStatus.indexOf(edits.status) !== -1 ? messages[edits.status] : (0,external_wp_i18n_namespaceObject.__)('Updating failed.');
4245
4246 // Check if message string contains HTML. Notice text is currently only
4247 // supported as plaintext, and stripping the tags may muddle the meaning.
4248 if (error.message && !/<\/?[^>]*>/.test(error.message)) {
4249 noticeMessage = [noticeMessage, error.message].join(' ');
4250 }
4251 return [noticeMessage, {
4252 id: SAVE_POST_NOTICE_ID
4253 }];
4254 }
4255
4256 /**
4257 * Builds the trash fail notification arguments for dispatch.
4258 *
4259 * @param {Object} data
4260 *
4261 * @return {Array} Arguments for dispatch.
4262 */
4263 function getNotificationArgumentsForTrashFail(data) {
4264 return [data.error.message && data.error.code !== 'unknown_error' ? data.error.message : (0,external_wp_i18n_namespaceObject.__)('Trashing failed'), {
4265 id: TRASH_POST_NOTICE_ID
4266 }];
4267 }
4268
4269 ;// ./packages/editor/build-module/store/actions.js
4270 /**
4271 * WordPress dependencies
4272 */
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284 /**
4285 * Internal dependencies
4286 */
4287
4288
4289
4290
4291 /**
4292 * Returns an action generator used in signalling that editor has initialized with
4293 * the specified post object and editor settings.
4294 *
4295 * @param {Object} post Post object.
4296 * @param {Object} edits Initial edited attributes object.
4297 * @param {Array?} template Block Template.
4298 */
4299 const setupEditor = (post, edits, template) => ({
4300 dispatch
4301 }) => {
4302 dispatch.setEditedPost(post.type, post.id);
4303 // Apply a template for new posts only, if exists.
4304 const isNewPost = post.status === 'auto-draft';
4305 if (isNewPost && template) {
4306 // In order to ensure maximum of a single parse during setup, edits are
4307 // included as part of editor setup action. Assume edited content as
4308 // canonical if provided, falling back to post.
4309 let content;
4310 if ('content' in edits) {
4311 content = edits.content;
4312 } else {
4313 content = post.content.raw;
4314 }
4315 let blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
4316 blocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
4317 dispatch.resetEditorBlocks(blocks, {
4318 __unstableShouldCreateUndoLevel: false
4319 });
4320 }
4321 if (edits && Object.values(edits).some(([key, edit]) => {
4322 var _post$key$raw;
4323 return edit !== ((_post$key$raw = post[key]?.raw) !== null && _post$key$raw !== void 0 ? _post$key$raw : post[key]);
4324 })) {
4325 dispatch.editPost(edits);
4326 }
4327 };
4328
4329 /**
4330 * Returns an action object signalling that the editor is being destroyed and
4331 * that any necessary state or side-effect cleanup should occur.
4332 *
4333 * @deprecated
4334 *
4335 * @return {Object} Action object.
4336 */
4337 function __experimentalTearDownEditor() {
4338 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor", {
4339 since: '6.5'
4340 });
4341 return {
4342 type: 'DO_NOTHING'
4343 };
4344 }
4345
4346 /**
4347 * Returns an action object used in signalling that the latest version of the
4348 * post has been received, either by initialization or save.
4349 *
4350 * @deprecated Since WordPress 6.0.
4351 */
4352 function resetPost() {
4353 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).resetPost", {
4354 since: '6.0',
4355 version: '6.3',
4356 alternative: 'Initialize the editor with the setupEditorState action'
4357 });
4358 return {
4359 type: 'DO_NOTHING'
4360 };
4361 }
4362
4363 /**
4364 * Returns an action object used in signalling that a patch of updates for the
4365 * latest version of the post have been received.
4366 *
4367 * @return {Object} Action object.
4368 * @deprecated since Gutenberg 9.7.0.
4369 */
4370 function updatePost() {
4371 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).updatePost", {
4372 since: '5.7',
4373 alternative: 'Use the core entities store instead'
4374 });
4375 return {
4376 type: 'DO_NOTHING'
4377 };
4378 }
4379
4380 /**
4381 * Setup the editor state.
4382 *
4383 * @deprecated
4384 *
4385 * @param {Object} post Post object.
4386 */
4387 function setupEditorState(post) {
4388 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).setupEditorState", {
4389 since: '6.5',
4390 alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost"
4391 });
4392 return setEditedPost(post.type, post.id);
4393 }
4394
4395 /**
4396 * Returns an action that sets the current post Type and post ID.
4397 *
4398 * @param {string} postType Post Type.
4399 * @param {string} postId Post ID.
4400 *
4401 * @return {Object} Action object.
4402 */
4403 function setEditedPost(postType, postId) {
4404 return {
4405 type: 'SET_EDITED_POST',
4406 postType,
4407 postId
4408 };
4409 }
4410
4411 /**
4412 * Returns an action object used in signalling that attributes of the post have
4413 * been edited.
4414 *
4415 * @param {Object} edits Post attributes to edit.
4416 * @param {Object} options Options for the edit.
4417 *
4418 * @example
4419 * ```js
4420 * // Update the post title
4421 * wp.data.dispatch( 'core/editor' ).editPost( { title: `${ newTitle }` } );
4422 * ```
4423 *
4424 * @example
4425 *```js
4426 * // Get specific media size based on the featured media ID
4427 * // Note: change sizes?.large for any registered size
4428 * const getFeaturedMediaUrl = useSelect( ( select ) => {
4429 * const getFeaturedMediaId =
4430 * select( 'core/editor' ).getEditedPostAttribute( 'featured_media' );
4431 * const getMedia = select( 'core' ).getMedia( getFeaturedMediaId );
4432 *
4433 * return (
4434 * getMedia?.media_details?.sizes?.large?.source_url || getMedia?.source_url || ''
4435 * );
4436 * }, [] );
4437 * ```
4438 *
4439 * @return {Object} Action object
4440 */
4441 const editPost = (edits, options) => ({
4442 select,
4443 registry
4444 }) => {
4445 const {
4446 id,
4447 type
4448 } = select.getCurrentPost();
4449 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', type, id, edits, options);
4450 };
4451
4452 /**
4453 * Action for saving the current post in the editor.
4454 *
4455 * @param {Object} options
4456 */
4457 const savePost = (options = {}) => async ({
4458 select,
4459 dispatch,
4460 registry
4461 }) => {
4462 if (!select.isEditedPostSaveable()) {
4463 return;
4464 }
4465 const content = select.getEditedPostContent();
4466 if (!options.isAutosave) {
4467 dispatch.editPost({
4468 content
4469 }, {
4470 undoIgnore: true
4471 });
4472 }
4473 const previousRecord = select.getCurrentPost();
4474 let edits = {
4475 id: previousRecord.id,
4476 ...registry.select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', previousRecord.type, previousRecord.id),
4477 content
4478 };
4479 dispatch({
4480 type: 'REQUEST_POST_UPDATE_START',
4481 options
4482 });
4483 let error = false;
4484 try {
4485 edits = await (0,external_wp_hooks_namespaceObject.applyFiltersAsync)('editor.preSavePost', edits, options);
4486 } catch (err) {
4487 error = err;
4488 }
4489 if (!error) {
4490 try {
4491 await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', previousRecord.type, edits, options);
4492 } catch (err) {
4493 error = err.message && err.code !== 'unknown_error' ? err.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating.');
4494 }
4495 }
4496 if (!error) {
4497 error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
4498 }
4499
4500 // Run the hook with legacy unstable name for backward compatibility
4501 if (!error) {
4502 try {
4503 await (0,external_wp_hooks_namespaceObject.applyFilters)('editor.__unstableSavePost', Promise.resolve(), options);
4504 } catch (err) {
4505 error = err;
4506 }
4507 }
4508 if (!error) {
4509 try {
4510 await (0,external_wp_hooks_namespaceObject.doActionAsync)('editor.savePost', {
4511 id: previousRecord.id
4512 }, options);
4513 } catch (err) {
4514 error = err;
4515 }
4516 }
4517 dispatch({
4518 type: 'REQUEST_POST_UPDATE_FINISH',
4519 options
4520 });
4521 if (error) {
4522 const args = getNotificationArgumentsForSaveFail({
4523 post: previousRecord,
4524 edits,
4525 error
4526 });
4527 if (args.length) {
4528 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...args);
4529 }
4530 } else {
4531 const updatedRecord = select.getCurrentPost();
4532 const args = getNotificationArgumentsForSaveSuccess({
4533 previousPost: previousRecord,
4534 post: updatedRecord,
4535 postType: await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(updatedRecord.type),
4536 options
4537 });
4538 if (args.length) {
4539 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(...args);
4540 }
4541 // Make sure that any edits after saving create an undo level and are
4542 // considered for change detection.
4543 if (!options.isAutosave) {
4544 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
4545 }
4546 }
4547 };
4548
4549 /**
4550 * Action for refreshing the current post.
4551 *
4552 * @deprecated Since WordPress 6.0.
4553 */
4554 function refreshPost() {
4555 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).refreshPost", {
4556 since: '6.0',
4557 version: '6.3',
4558 alternative: 'Use the core entities store instead'
4559 });
4560 return {
4561 type: 'DO_NOTHING'
4562 };
4563 }
4564
4565 /**
4566 * Action for trashing the current post in the editor.
4567 */
4568 const trashPost = () => async ({
4569 select,
4570 dispatch,
4571 registry
4572 }) => {
4573 const postTypeSlug = select.getCurrentPostType();
4574 const postType = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
4575 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(TRASH_POST_NOTICE_ID);
4576 const {
4577 rest_base: restBase,
4578 rest_namespace: restNamespace = 'wp/v2'
4579 } = postType;
4580 dispatch({
4581 type: 'REQUEST_POST_DELETE_START'
4582 });
4583 try {
4584 const post = select.getCurrentPost();
4585 await external_wp_apiFetch_default()({
4586 path: `/${restNamespace}/${restBase}/${post.id}`,
4587 method: 'DELETE'
4588 });
4589 await dispatch.savePost();
4590 } catch (error) {
4591 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...getNotificationArgumentsForTrashFail({
4592 error
4593 }));
4594 }
4595 dispatch({
4596 type: 'REQUEST_POST_DELETE_FINISH'
4597 });
4598 };
4599
4600 /**
4601 * Action that autosaves the current post. This
4602 * includes server-side autosaving (default) and client-side (a.k.a. local)
4603 * autosaving (e.g. on the Web, the post might be committed to Session
4604 * Storage).
4605 *
4606 * @param {Object?} options Extra flags to identify the autosave.
4607 */
4608 const autosave = ({
4609 local = false,
4610 ...options
4611 } = {}) => async ({
4612 select,
4613 dispatch
4614 }) => {
4615 const post = select.getCurrentPost();
4616
4617 // Currently template autosaving is not supported.
4618 if (post.type === 'wp_template') {
4619 return;
4620 }
4621 if (local) {
4622 const isPostNew = select.isEditedPostNew();
4623 const title = select.getEditedPostAttribute('title');
4624 const content = select.getEditedPostAttribute('content');
4625 const excerpt = select.getEditedPostAttribute('excerpt');
4626 localAutosaveSet(post.id, isPostNew, title, content, excerpt);
4627 } else {
4628 await dispatch.savePost({
4629 isAutosave: true,
4630 ...options
4631 });
4632 }
4633 };
4634 const __unstableSaveForPreview = ({
4635 forceIsAutosaveable
4636 } = {}) => async ({
4637 select,
4638 dispatch
4639 }) => {
4640 if ((forceIsAutosaveable || select.isEditedPostAutosaveable()) && !select.isPostLocked()) {
4641 const isDraft = ['draft', 'auto-draft'].includes(select.getEditedPostAttribute('status'));
4642 if (isDraft) {
4643 await dispatch.savePost({
4644 isPreview: true
4645 });
4646 } else {
4647 await dispatch.autosave({
4648 isPreview: true
4649 });
4650 }
4651 }
4652 return select.getEditedPostPreviewLink();
4653 };
4654
4655 /**
4656 * Action that restores last popped state in undo history.
4657 */
4658 const redo = () => ({
4659 registry
4660 }) => {
4661 registry.dispatch(external_wp_coreData_namespaceObject.store).redo();
4662 };
4663
4664 /**
4665 * Action that pops a record from undo history and undoes the edit.
4666 */
4667 const undo = () => ({
4668 registry
4669 }) => {
4670 registry.dispatch(external_wp_coreData_namespaceObject.store).undo();
4671 };
4672
4673 /**
4674 * Action that creates an undo history record.
4675 *
4676 * @deprecated Since WordPress 6.0
4677 */
4678 function createUndoLevel() {
4679 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
4680 since: '6.0',
4681 version: '6.3',
4682 alternative: 'Use the core entities store instead'
4683 });
4684 return {
4685 type: 'DO_NOTHING'
4686 };
4687 }
4688
4689 /**
4690 * Action that locks the editor.
4691 *
4692 * @param {Object} lock Details about the post lock status, user, and nonce.
4693 * @return {Object} Action object.
4694 */
4695 function updatePostLock(lock) {
4696 return {
4697 type: 'UPDATE_POST_LOCK',
4698 lock
4699 };
4700 }
4701
4702 /**
4703 * Enable the publish sidebar.
4704 */
4705 const enablePublishSidebar = () => ({
4706 registry
4707 }) => {
4708 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', true);
4709 };
4710
4711 /**
4712 * Disables the publish sidebar.
4713 */
4714 const disablePublishSidebar = () => ({
4715 registry
4716 }) => {
4717 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', false);
4718 };
4719
4720 /**
4721 * Action that locks post saving.
4722 *
4723 * @param {string} lockName The lock name.
4724 *
4725 * @example
4726 * ```
4727 * const { subscribe } = wp.data;
4728 *
4729 * const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4730 *
4731 * // Only allow publishing posts that are set to a future date.
4732 * if ( 'publish' !== initialPostStatus ) {
4733 *
4734 * // Track locking.
4735 * let locked = false;
4736 *
4737 * // Watch for the publish event.
4738 * let unssubscribe = subscribe( () => {
4739 * const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4740 * if ( 'publish' !== currentPostStatus ) {
4741 *
4742 * // Compare the post date to the current date, lock the post if the date isn't in the future.
4743 * const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) );
4744 * const currentDate = new Date();
4745 * if ( postDate.getTime() <= currentDate.getTime() ) {
4746 * if ( ! locked ) {
4747 * locked = true;
4748 * wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' );
4749 * }
4750 * } else {
4751 * if ( locked ) {
4752 * locked = false;
4753 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' );
4754 * }
4755 * }
4756 * }
4757 * } );
4758 * }
4759 * ```
4760 *
4761 * @return {Object} Action object
4762 */
4763 function lockPostSaving(lockName) {
4764 return {
4765 type: 'LOCK_POST_SAVING',
4766 lockName
4767 };
4768 }
4769
4770 /**
4771 * Action that unlocks post saving.
4772 *
4773 * @param {string} lockName The lock name.
4774 *
4775 * @example
4776 * ```
4777 * // Unlock post saving with the lock key `mylock`:
4778 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );
4779 * ```
4780 *
4781 * @return {Object} Action object
4782 */
4783 function unlockPostSaving(lockName) {
4784 return {
4785 type: 'UNLOCK_POST_SAVING',
4786 lockName
4787 };
4788 }
4789
4790 /**
4791 * Action that locks post autosaving.
4792 *
4793 * @param {string} lockName The lock name.
4794 *
4795 * @example
4796 * ```
4797 * // Lock post autosaving with the lock key `mylock`:
4798 * wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' );
4799 * ```
4800 *
4801 * @return {Object} Action object
4802 */
4803 function lockPostAutosaving(lockName) {
4804 return {
4805 type: 'LOCK_POST_AUTOSAVING',
4806 lockName
4807 };
4808 }
4809
4810 /**
4811 * Action that unlocks post autosaving.
4812 *
4813 * @param {string} lockName The lock name.
4814 *
4815 * @example
4816 * ```
4817 * // Unlock post saving with the lock key `mylock`:
4818 * wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' );
4819 * ```
4820 *
4821 * @return {Object} Action object
4822 */
4823 function unlockPostAutosaving(lockName) {
4824 return {
4825 type: 'UNLOCK_POST_AUTOSAVING',
4826 lockName
4827 };
4828 }
4829
4830 /**
4831 * Returns an action object used to signal that the blocks have been updated.
4832 *
4833 * @param {Array} blocks Block Array.
4834 * @param {?Object} options Optional options.
4835 */
4836 const resetEditorBlocks = (blocks, options = {}) => ({
4837 select,
4838 dispatch,
4839 registry
4840 }) => {
4841 const {
4842 __unstableShouldCreateUndoLevel,
4843 selection
4844 } = options;
4845 const edits = {
4846 blocks,
4847 selection
4848 };
4849 if (__unstableShouldCreateUndoLevel !== false) {
4850 const {
4851 id,
4852 type
4853 } = select.getCurrentPost();
4854 const noChange = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', type, id).blocks === edits.blocks;
4855 if (noChange) {
4856 registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableCreateUndoLevel('postType', type, id);
4857 return;
4858 }
4859
4860 // We create a new function here on every persistent edit
4861 // to make sure the edit makes the post dirty and creates
4862 // a new undo level.
4863 edits.content = ({
4864 blocks: blocksForSerialization = []
4865 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
4866 }
4867 dispatch.editPost(edits);
4868 };
4869
4870 /*
4871 * Returns an action object used in signalling that the post editor settings have been updated.
4872 *
4873 * @param {Object} settings Updated settings
4874 *
4875 * @return {Object} Action object
4876 */
4877 function updateEditorSettings(settings) {
4878 return {
4879 type: 'UPDATE_EDITOR_SETTINGS',
4880 settings
4881 };
4882 }
4883
4884 /**
4885 * Returns an action used to set the rendering mode of the post editor. We support multiple rendering modes:
4886 *
4887 * - `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.
4888 * - `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.
4889 *
4890 * @param {string} mode Mode (one of 'post-only' or 'template-locked').
4891 */
4892 const setRenderingMode = mode => ({
4893 dispatch,
4894 registry,
4895 select
4896 }) => {
4897 if (select.__unstableIsEditorReady()) {
4898 // We clear the block selection but we also need to clear the selection from the core store.
4899 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
4900 dispatch.editPost({
4901 selection: undefined
4902 }, {
4903 undoIgnore: true
4904 });
4905 }
4906 dispatch({
4907 type: 'SET_RENDERING_MODE',
4908 mode
4909 });
4910 };
4911
4912 /**
4913 * Action that changes the width of the editing canvas.
4914 *
4915 * @param {string} deviceType
4916 *
4917 * @return {Object} Action object.
4918 */
4919 function setDeviceType(deviceType) {
4920 return {
4921 type: 'SET_DEVICE_TYPE',
4922 deviceType
4923 };
4924 }
4925
4926 /**
4927 * Returns an action object used to enable or disable a panel in the editor.
4928 *
4929 * @param {string} panelName A string that identifies the panel to enable or disable.
4930 *
4931 * @return {Object} Action object.
4932 */
4933 const toggleEditorPanelEnabled = panelName => ({
4934 registry
4935 }) => {
4936 var _registry$select$get;
4937 const inactivePanels = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
4938 const isPanelInactive = !!inactivePanels?.includes(panelName);
4939
4940 // If the panel is inactive, remove it to enable it, else add it to
4941 // make it inactive.
4942 let updatedInactivePanels;
4943 if (isPanelInactive) {
4944 updatedInactivePanels = inactivePanels.filter(invactivePanelName => invactivePanelName !== panelName);
4945 } else {
4946 updatedInactivePanels = [...inactivePanels, panelName];
4947 }
4948 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'inactivePanels', updatedInactivePanels);
4949 };
4950
4951 /**
4952 * Opens a closed panel and closes an open panel.
4953 *
4954 * @param {string} panelName A string that identifies the panel to open or close.
4955 */
4956 const toggleEditorPanelOpened = panelName => ({
4957 registry
4958 }) => {
4959 var _registry$select$get2;
4960 const openPanels = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
4961 const isPanelOpen = !!openPanels?.includes(panelName);
4962
4963 // If the panel is open, remove it to close it, else add it to
4964 // make it open.
4965 let updatedOpenPanels;
4966 if (isPanelOpen) {
4967 updatedOpenPanels = openPanels.filter(openPanelName => openPanelName !== panelName);
4968 } else {
4969 updatedOpenPanels = [...openPanels, panelName];
4970 }
4971 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'openPanels', updatedOpenPanels);
4972 };
4973
4974 /**
4975 * Returns an action object used to remove a panel from the editor.
4976 *
4977 * @param {string} panelName A string that identifies the panel to remove.
4978 *
4979 * @return {Object} Action object.
4980 */
4981 function removeEditorPanel(panelName) {
4982 return {
4983 type: 'REMOVE_PANEL',
4984 panelName
4985 };
4986 }
4987
4988 /**
4989 * Returns an action object used to open/close the inserter.
4990 *
4991 * @param {boolean|Object} value Whether the inserter should be
4992 * opened (true) or closed (false).
4993 * To specify an insertion point,
4994 * use an object.
4995 * @param {string} value.rootClientId The root client ID to insert at.
4996 * @param {number} value.insertionIndex The index to insert at.
4997 * @param {string} value.filterValue A query to filter the inserter results.
4998 * @param {Function} value.onSelect A callback when an item is selected.
4999 * @param {string} value.tab The tab to open in the inserter.
5000 * @param {string} value.category The category to initialize in the inserter.
5001 *
5002 * @return {Object} Action object.
5003 */
5004 const setIsInserterOpened = value => ({
5005 dispatch,
5006 registry
5007 }) => {
5008 if (typeof value === 'object' && value.hasOwnProperty('rootClientId') && value.hasOwnProperty('insertionIndex')) {
5009 unlock(registry.dispatch(external_wp_blockEditor_namespaceObject.store)).setInsertionPoint({
5010 rootClientId: value.rootClientId,
5011 index: value.insertionIndex
5012 });
5013 }
5014 dispatch({
5015 type: 'SET_IS_INSERTER_OPENED',
5016 value
5017 });
5018 };
5019
5020 /**
5021 * Returns an action object used to open/close the list view.
5022 *
5023 * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
5024 * @return {Object} Action object.
5025 */
5026 function setIsListViewOpened(isOpen) {
5027 return {
5028 type: 'SET_IS_LIST_VIEW_OPENED',
5029 isOpen
5030 };
5031 }
5032
5033 /**
5034 * Action that toggles Distraction free mode.
5035 * Distraction free mode expects there are no sidebars, as due to the
5036 * z-index values set, you can't close sidebars.
5037 */
5038 const toggleDistractionFree = () => ({
5039 dispatch,
5040 registry
5041 }) => {
5042 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
5043 if (isDistractionFree) {
5044 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', false);
5045 }
5046 if (!isDistractionFree) {
5047 registry.batch(() => {
5048 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', true);
5049 dispatch.setIsInserterOpened(false);
5050 dispatch.setIsListViewOpened(false);
5051 });
5052 }
5053 registry.batch(() => {
5054 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'distractionFree', !isDistractionFree);
5055 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.'), {
5056 id: 'core/editor/distraction-free-mode/notice',
5057 type: 'snackbar',
5058 actions: [{
5059 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5060 onClick: () => {
5061 registry.batch(() => {
5062 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', isDistractionFree ? true : false);
5063 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'distractionFree');
5064 });
5065 }
5066 }]
5067 });
5068 });
5069 };
5070
5071 /**
5072 * Triggers an action used to switch editor mode.
5073 *
5074 * @param {string} mode The editor mode.
5075 */
5076 const switchEditorMode = mode => ({
5077 dispatch,
5078 registry
5079 }) => {
5080 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'editorMode', mode);
5081 if (mode !== 'visual') {
5082 // Unselect blocks when we switch to a non visual mode.
5083 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
5084 // Exit zoom out state when switching to a non visual mode.
5085 unlock(registry.dispatch(external_wp_blockEditor_namespaceObject.store)).resetZoomLevel();
5086 }
5087 if (mode === 'visual') {
5088 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
5089 } else if (mode === 'text') {
5090 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
5091 if (isDistractionFree) {
5092 dispatch.toggleDistractionFree();
5093 }
5094 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Code editor selected'), 'assertive');
5095 }
5096 };
5097
5098 /**
5099 * Returns an action object used in signalling that the user opened the publish
5100 * sidebar.
5101 *
5102 * @return {Object} Action object
5103 */
5104 function openPublishSidebar() {
5105 return {
5106 type: 'OPEN_PUBLISH_SIDEBAR'
5107 };
5108 }
5109
5110 /**
5111 * Returns an action object used in signalling that the user closed the
5112 * publish sidebar.
5113 *
5114 * @return {Object} Action object.
5115 */
5116 function closePublishSidebar() {
5117 return {
5118 type: 'CLOSE_PUBLISH_SIDEBAR'
5119 };
5120 }
5121
5122 /**
5123 * Returns an action object used in signalling that the user toggles the publish sidebar.
5124 *
5125 * @return {Object} Action object
5126 */
5127 function togglePublishSidebar() {
5128 return {
5129 type: 'TOGGLE_PUBLISH_SIDEBAR'
5130 };
5131 }
5132
5133 /**
5134 * Backward compatibility
5135 */
5136
5137 const getBlockEditorAction = name => (...args) => ({
5138 registry
5139 }) => {
5140 external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', {
5141 since: '5.3',
5142 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
5143 version: '6.2'
5144 });
5145 registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args);
5146 };
5147
5148 /**
5149 * @see resetBlocks in core/block-editor store.
5150 */
5151 const resetBlocks = getBlockEditorAction('resetBlocks');
5152
5153 /**
5154 * @see receiveBlocks in core/block-editor store.
5155 */
5156 const receiveBlocks = getBlockEditorAction('receiveBlocks');
5157
5158 /**
5159 * @see updateBlock in core/block-editor store.
5160 */
5161 const updateBlock = getBlockEditorAction('updateBlock');
5162
5163 /**
5164 * @see updateBlockAttributes in core/block-editor store.
5165 */
5166 const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes');
5167
5168 /**
5169 * @see selectBlock in core/block-editor store.
5170 */
5171 const selectBlock = getBlockEditorAction('selectBlock');
5172
5173 /**
5174 * @see startMultiSelect in core/block-editor store.
5175 */
5176 const startMultiSelect = getBlockEditorAction('startMultiSelect');
5177
5178 /**
5179 * @see stopMultiSelect in core/block-editor store.
5180 */
5181 const stopMultiSelect = getBlockEditorAction('stopMultiSelect');
5182
5183 /**
5184 * @see multiSelect in core/block-editor store.
5185 */
5186 const multiSelect = getBlockEditorAction('multiSelect');
5187
5188 /**
5189 * @see clearSelectedBlock in core/block-editor store.
5190 */
5191 const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock');
5192
5193 /**
5194 * @see toggleSelection in core/block-editor store.
5195 */
5196 const toggleSelection = getBlockEditorAction('toggleSelection');
5197
5198 /**
5199 * @see replaceBlocks in core/block-editor store.
5200 */
5201 const replaceBlocks = getBlockEditorAction('replaceBlocks');
5202
5203 /**
5204 * @see replaceBlock in core/block-editor store.
5205 */
5206 const replaceBlock = getBlockEditorAction('replaceBlock');
5207
5208 /**
5209 * @see moveBlocksDown in core/block-editor store.
5210 */
5211 const moveBlocksDown = getBlockEditorAction('moveBlocksDown');
5212
5213 /**
5214 * @see moveBlocksUp in core/block-editor store.
5215 */
5216 const moveBlocksUp = getBlockEditorAction('moveBlocksUp');
5217
5218 /**
5219 * @see moveBlockToPosition in core/block-editor store.
5220 */
5221 const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition');
5222
5223 /**
5224 * @see insertBlock in core/block-editor store.
5225 */
5226 const insertBlock = getBlockEditorAction('insertBlock');
5227
5228 /**
5229 * @see insertBlocks in core/block-editor store.
5230 */
5231 const insertBlocks = getBlockEditorAction('insertBlocks');
5232
5233 /**
5234 * @see showInsertionPoint in core/block-editor store.
5235 */
5236 const showInsertionPoint = getBlockEditorAction('showInsertionPoint');
5237
5238 /**
5239 * @see hideInsertionPoint in core/block-editor store.
5240 */
5241 const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint');
5242
5243 /**
5244 * @see setTemplateValidity in core/block-editor store.
5245 */
5246 const setTemplateValidity = getBlockEditorAction('setTemplateValidity');
5247
5248 /**
5249 * @see synchronizeTemplate in core/block-editor store.
5250 */
5251 const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate');
5252
5253 /**
5254 * @see mergeBlocks in core/block-editor store.
5255 */
5256 const mergeBlocks = getBlockEditorAction('mergeBlocks');
5257
5258 /**
5259 * @see removeBlocks in core/block-editor store.
5260 */
5261 const removeBlocks = getBlockEditorAction('removeBlocks');
5262
5263 /**
5264 * @see removeBlock in core/block-editor store.
5265 */
5266 const removeBlock = getBlockEditorAction('removeBlock');
5267
5268 /**
5269 * @see toggleBlockMode in core/block-editor store.
5270 */
5271 const toggleBlockMode = getBlockEditorAction('toggleBlockMode');
5272
5273 /**
5274 * @see startTyping in core/block-editor store.
5275 */
5276 const startTyping = getBlockEditorAction('startTyping');
5277
5278 /**
5279 * @see stopTyping in core/block-editor store.
5280 */
5281 const stopTyping = getBlockEditorAction('stopTyping');
5282
5283 /**
5284 * @see enterFormattedText in core/block-editor store.
5285 */
5286 const enterFormattedText = getBlockEditorAction('enterFormattedText');
5287
5288 /**
5289 * @see exitFormattedText in core/block-editor store.
5290 */
5291 const exitFormattedText = getBlockEditorAction('exitFormattedText');
5292
5293 /**
5294 * @see insertDefaultBlock in core/block-editor store.
5295 */
5296 const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock');
5297
5298 /**
5299 * @see updateBlockListSettings in core/block-editor store.
5300 */
5301 const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings');
5302
5303 ;// external ["wp","htmlEntities"]
5304 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
5305 ;// ./packages/editor/build-module/store/utils/is-template-revertable.js
5306 /**
5307 * Internal dependencies
5308 */
5309
5310
5311 // Copy of the function from packages/edit-site/src/utils/is-template-revertable.js
5312
5313 /**
5314 * Check if a template or template part is revertable to its original theme-provided file.
5315 *
5316 * @param {Object} templateOrTemplatePart The entity to check.
5317 * @return {boolean} Whether the entity is revertable.
5318 */
5319 function isTemplateRevertable(templateOrTemplatePart) {
5320 if (!templateOrTemplatePart) {
5321 return false;
5322 }
5323 return templateOrTemplatePart.source === constants_TEMPLATE_ORIGINS.custom && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file);
5324 }
5325
5326 ;// ./packages/icons/build-module/library/external.js
5327 /**
5328 * WordPress dependencies
5329 */
5330
5331
5332 const external = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5333 xmlns: "http://www.w3.org/2000/svg",
5334 viewBox: "0 0 24 24",
5335 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5336 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"
5337 })
5338 });
5339 /* harmony default export */ const library_external = (external);
5340
5341 ;// ./packages/fields/build-module/actions/view-post.js
5342 /**
5343 * WordPress dependencies
5344 */
5345
5346
5347
5348 /**
5349 * Internal dependencies
5350 */
5351
5352 const viewPost = {
5353 id: 'view-post',
5354 label: (0,external_wp_i18n_namespaceObject._x)('View', 'verb'),
5355 isPrimary: true,
5356 icon: library_external,
5357 isEligible(post) {
5358 return post.status !== 'trash';
5359 },
5360 callback(posts, {
5361 onActionPerformed
5362 }) {
5363 const post = posts[0];
5364 window.open(post?.link, '_blank');
5365 if (onActionPerformed) {
5366 onActionPerformed(posts);
5367 }
5368 }
5369 };
5370 /* harmony default export */ const view_post = (viewPost);
5371
5372 ;// ./packages/fields/build-module/actions/view-post-revisions.js
5373 /**
5374 * WordPress dependencies
5375 */
5376
5377
5378
5379 /**
5380 * Internal dependencies
5381 */
5382
5383 const viewPostRevisions = {
5384 id: 'view-post-revisions',
5385 context: 'list',
5386 label(items) {
5387 var _items$0$_links$versi;
5388 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;
5389 return (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: number of revisions. */
5390 (0,external_wp_i18n_namespaceObject.__)('View revisions (%s)'), revisionsCount);
5391 },
5392 isEligible(post) {
5393 var _post$_links$predeces, _post$_links$version;
5394 if (post.status === 'trash') {
5395 return false;
5396 }
5397 const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
5398 const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
5399 return !!lastRevisionId && revisionsCount > 1;
5400 },
5401 callback(posts, {
5402 onActionPerformed
5403 }) {
5404 const post = posts[0];
5405 const href = (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
5406 revision: post?._links?.['predecessor-version']?.[0]?.id
5407 });
5408 document.location.href = href;
5409 if (onActionPerformed) {
5410 onActionPerformed(posts);
5411 }
5412 }
5413 };
5414 /* harmony default export */ const view_post_revisions = (viewPostRevisions);
5415
5416 ;// external ["wp","components"]
5417 const external_wp_components_namespaceObject = window["wp"]["components"];
5418 ;// ./packages/dataviews/build-module/field-types/integer.js
5419 /**
5420 * Internal dependencies
5421 */
5422
5423 function sort(a, b, direction) {
5424 return direction === 'asc' ? a - b : b - a;
5425 }
5426 function isValid(value, context) {
5427 // TODO: this implicitely means the value is required.
5428 if (value === '') {
5429 return false;
5430 }
5431 if (!Number.isInteger(Number(value))) {
5432 return false;
5433 }
5434 if (context?.elements) {
5435 const validValues = context?.elements.map(f => f.value);
5436 if (!validValues.includes(Number(value))) {
5437 return false;
5438 }
5439 }
5440 return true;
5441 }
5442 /* harmony default export */ const integer = ({
5443 sort,
5444 isValid,
5445 Edit: 'integer'
5446 });
5447
5448 ;// ./packages/dataviews/build-module/field-types/text.js
5449 /**
5450 * Internal dependencies
5451 */
5452
5453 function text_sort(valueA, valueB, direction) {
5454 return direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
5455 }
5456 function text_isValid(value, context) {
5457 if (context?.elements) {
5458 const validValues = context?.elements?.map(f => f.value);
5459 if (!validValues.includes(value)) {
5460 return false;
5461 }
5462 }
5463 return true;
5464 }
5465 /* harmony default export */ const field_types_text = ({
5466 sort: text_sort,
5467 isValid: text_isValid,
5468 Edit: 'text'
5469 });
5470
5471 ;// ./packages/dataviews/build-module/field-types/datetime.js
5472 /**
5473 * Internal dependencies
5474 */
5475
5476 function datetime_sort(a, b, direction) {
5477 const timeA = new Date(a).getTime();
5478 const timeB = new Date(b).getTime();
5479 return direction === 'asc' ? timeA - timeB : timeB - timeA;
5480 }
5481 function datetime_isValid(value, context) {
5482 if (context?.elements) {
5483 const validValues = context?.elements.map(f => f.value);
5484 if (!validValues.includes(value)) {
5485 return false;
5486 }
5487 }
5488 return true;
5489 }
5490 /* harmony default export */ const datetime = ({
5491 sort: datetime_sort,
5492 isValid: datetime_isValid,
5493 Edit: 'datetime'
5494 });
5495
5496 ;// ./packages/dataviews/build-module/field-types/index.js
5497 /**
5498 * Internal dependencies
5499 */
5500
5501
5502
5503
5504
5505 /**
5506 *
5507 * @param {FieldType} type The field type definition to get.
5508 *
5509 * @return A field type definition.
5510 */
5511 function getFieldTypeDefinition(type) {
5512 if ('integer' === type) {
5513 return integer;
5514 }
5515 if ('text' === type) {
5516 return field_types_text;
5517 }
5518 if ('datetime' === type) {
5519 return datetime;
5520 }
5521 return {
5522 sort: (a, b, direction) => {
5523 if (typeof a === 'number' && typeof b === 'number') {
5524 return direction === 'asc' ? a - b : b - a;
5525 }
5526 return direction === 'asc' ? a.localeCompare(b) : b.localeCompare(a);
5527 },
5528 isValid: (value, context) => {
5529 if (context?.elements) {
5530 const validValues = context?.elements?.map(f => f.value);
5531 if (!validValues.includes(value)) {
5532 return false;
5533 }
5534 }
5535 return true;
5536 },
5537 Edit: () => null
5538 };
5539 }
5540
5541 ;// ./packages/dataviews/build-module/dataform-controls/datetime.js
5542 /**
5543 * WordPress dependencies
5544 */
5545
5546
5547
5548 /**
5549 * Internal dependencies
5550 */
5551
5552 function DateTime({
5553 data,
5554 field,
5555 onChange,
5556 hideLabelFromVision
5557 }) {
5558 const {
5559 id,
5560 label
5561 } = field;
5562 const value = field.getValue({
5563 item: data
5564 });
5565 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5566 [id]: newValue
5567 }), [id, onChange]);
5568 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
5569 className: "dataviews-controls__datetime",
5570 children: [!hideLabelFromVision && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
5571 as: "legend",
5572 children: label
5573 }), hideLabelFromVision && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
5574 as: "legend",
5575 children: label
5576 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TimePicker, {
5577 currentTime: value,
5578 onChange: onChangeControl,
5579 hideLabelFromVision: true
5580 })]
5581 });
5582 }
5583
5584 ;// ./packages/dataviews/build-module/dataform-controls/integer.js
5585 /**
5586 * WordPress dependencies
5587 */
5588
5589
5590
5591 /**
5592 * Internal dependencies
5593 */
5594
5595 function Integer({
5596 data,
5597 field,
5598 onChange,
5599 hideLabelFromVision
5600 }) {
5601 var _field$getValue;
5602 const {
5603 id,
5604 label,
5605 description
5606 } = field;
5607 const value = (_field$getValue = field.getValue({
5608 item: data
5609 })) !== null && _field$getValue !== void 0 ? _field$getValue : '';
5610 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5611 [id]: Number(newValue)
5612 }), [id, onChange]);
5613 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
5614 label: label,
5615 help: description,
5616 value: value,
5617 onChange: onChangeControl,
5618 __next40pxDefaultSize: true,
5619 hideLabelFromVision: hideLabelFromVision
5620 });
5621 }
5622
5623 ;// ./packages/dataviews/build-module/dataform-controls/radio.js
5624 /**
5625 * WordPress dependencies
5626 */
5627
5628
5629
5630 /**
5631 * Internal dependencies
5632 */
5633
5634 function Radio({
5635 data,
5636 field,
5637 onChange,
5638 hideLabelFromVision
5639 }) {
5640 const {
5641 id,
5642 label
5643 } = field;
5644 const value = field.getValue({
5645 item: data
5646 });
5647 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5648 [id]: newValue
5649 }), [id, onChange]);
5650 if (field.elements) {
5651 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
5652 label: label,
5653 onChange: onChangeControl,
5654 options: field.elements,
5655 selected: value,
5656 hideLabelFromVision: hideLabelFromVision
5657 });
5658 }
5659 return null;
5660 }
5661
5662 ;// ./packages/dataviews/build-module/dataform-controls/select.js
5663 /**
5664 * WordPress dependencies
5665 */
5666
5667
5668
5669
5670 /**
5671 * Internal dependencies
5672 */
5673
5674 function Select({
5675 data,
5676 field,
5677 onChange,
5678 hideLabelFromVision
5679 }) {
5680 var _field$getValue, _field$elements;
5681 const {
5682 id,
5683 label
5684 } = field;
5685 const value = (_field$getValue = field.getValue({
5686 item: data
5687 })) !== null && _field$getValue !== void 0 ? _field$getValue : '';
5688 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5689 [id]: newValue
5690 }), [id, onChange]);
5691 const elements = [
5692 /*
5693 * Value can be undefined when:
5694 *
5695 * - the field is not required
5696 * - in bulk editing
5697 *
5698 */
5699 {
5700 label: (0,external_wp_i18n_namespaceObject.__)('Select item'),
5701 value: ''
5702 }, ...((_field$elements = field?.elements) !== null && _field$elements !== void 0 ? _field$elements : [])];
5703 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
5704 label: label,
5705 value: value,
5706 options: elements,
5707 onChange: onChangeControl,
5708 __next40pxDefaultSize: true,
5709 __nextHasNoMarginBottom: true,
5710 hideLabelFromVision: hideLabelFromVision
5711 });
5712 }
5713
5714 ;// ./packages/dataviews/build-module/dataform-controls/text.js
5715 /**
5716 * WordPress dependencies
5717 */
5718
5719
5720
5721 /**
5722 * Internal dependencies
5723 */
5724
5725 function Text({
5726 data,
5727 field,
5728 onChange,
5729 hideLabelFromVision
5730 }) {
5731 const {
5732 id,
5733 label,
5734 placeholder
5735 } = field;
5736 const value = field.getValue({
5737 item: data
5738 });
5739 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5740 [id]: newValue
5741 }), [id, onChange]);
5742 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
5743 label: label,
5744 placeholder: placeholder,
5745 value: value !== null && value !== void 0 ? value : '',
5746 onChange: onChangeControl,
5747 __next40pxDefaultSize: true,
5748 __nextHasNoMarginBottom: true,
5749 hideLabelFromVision: hideLabelFromVision
5750 });
5751 }
5752
5753 ;// ./packages/dataviews/build-module/dataform-controls/index.js
5754 /**
5755 * External dependencies
5756 */
5757
5758 /**
5759 * Internal dependencies
5760 */
5761
5762
5763
5764
5765
5766
5767 const FORM_CONTROLS = {
5768 datetime: DateTime,
5769 integer: Integer,
5770 radio: Radio,
5771 select: Select,
5772 text: Text
5773 };
5774 function getControl(field, fieldTypeDefinition) {
5775 if (typeof field.Edit === 'function') {
5776 return field.Edit;
5777 }
5778 if (typeof field.Edit === 'string') {
5779 return getControlByType(field.Edit);
5780 }
5781 if (field.elements) {
5782 return getControlByType('select');
5783 }
5784 if (typeof fieldTypeDefinition.Edit === 'string') {
5785 return getControlByType(fieldTypeDefinition.Edit);
5786 }
5787 return fieldTypeDefinition.Edit;
5788 }
5789 function getControlByType(type) {
5790 if (Object.keys(FORM_CONTROLS).includes(type)) {
5791 return FORM_CONTROLS[type];
5792 }
5793 throw 'Control ' + type + ' not found';
5794 }
5795
5796 ;// ./packages/dataviews/build-module/components/dataform-combined-edit/index.js
5797 /**
5798 * WordPress dependencies
5799 */
5800
5801
5802 /**
5803 * Internal dependencies
5804 */
5805
5806 function Header({
5807 title
5808 }) {
5809 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
5810 className: "dataforms-layouts__dropdown-header",
5811 spacing: 4,
5812 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
5813 alignment: "center",
5814 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHeading, {
5815 level: 2,
5816 size: 13,
5817 children: title
5818 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalSpacer, {})]
5819 })
5820 });
5821 }
5822 function DataFormCombinedEdit({
5823 field,
5824 data,
5825 onChange,
5826 hideLabelFromVision
5827 }) {
5828 var _field$children;
5829 const className = 'dataforms-combined-edit';
5830 const visibleChildren = ((_field$children = field.children) !== null && _field$children !== void 0 ? _field$children : []).map(fieldId => field.fields.find(({
5831 id
5832 }) => id === fieldId)).filter(childField => !!childField);
5833 const children = visibleChildren.map(child => {
5834 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
5835 className: "dataforms-combined-edit__field",
5836 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(child.Edit, {
5837 data: data,
5838 field: child,
5839 onChange: onChange
5840 })
5841 }, child.id);
5842 });
5843 const Stack = field.direction === 'horizontal' ? external_wp_components_namespaceObject.__experimentalHStack : external_wp_components_namespaceObject.__experimentalVStack;
5844 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
5845 children: [!hideLabelFromVision && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Header, {
5846 title: field.label
5847 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Stack, {
5848 spacing: 4,
5849 className: className,
5850 as: "fieldset",
5851 children: children
5852 })]
5853 });
5854 }
5855 /* harmony default export */ const dataform_combined_edit = (DataFormCombinedEdit);
5856
5857 ;// ./packages/dataviews/build-module/normalize-fields.js
5858 /**
5859 * Internal dependencies
5860 */
5861
5862
5863
5864
5865 /**
5866 * Apply default values and normalize the fields config.
5867 *
5868 * @param fields Fields config.
5869 * @return Normalized fields config.
5870 */
5871 function normalizeFields(fields) {
5872 return fields.map(field => {
5873 var _field$sort, _field$isValid, _field$enableHiding, _field$enableSorting;
5874 const fieldTypeDefinition = getFieldTypeDefinition(field.type);
5875 const getValue = field.getValue || (({
5876 item
5877 }) => item[field.id]);
5878 const sort = (_field$sort = field.sort) !== null && _field$sort !== void 0 ? _field$sort : function sort(a, b, direction) {
5879 return fieldTypeDefinition.sort(getValue({
5880 item: a
5881 }), getValue({
5882 item: b
5883 }), direction);
5884 };
5885 const isValid = (_field$isValid = field.isValid) !== null && _field$isValid !== void 0 ? _field$isValid : function isValid(item, context) {
5886 return fieldTypeDefinition.isValid(getValue({
5887 item
5888 }), context);
5889 };
5890 const Edit = getControl(field, fieldTypeDefinition);
5891 const renderFromElements = ({
5892 item
5893 }) => {
5894 const value = getValue({
5895 item
5896 });
5897 return field?.elements?.find(element => element.value === value)?.label || getValue({
5898 item
5899 });
5900 };
5901 const render = field.render || (field.elements ? renderFromElements : getValue);
5902 return {
5903 ...field,
5904 label: field.label || field.id,
5905 header: field.header || field.label || field.id,
5906 getValue,
5907 render,
5908 sort,
5909 isValid,
5910 Edit,
5911 enableHiding: (_field$enableHiding = field.enableHiding) !== null && _field$enableHiding !== void 0 ? _field$enableHiding : true,
5912 enableSorting: (_field$enableSorting = field.enableSorting) !== null && _field$enableSorting !== void 0 ? _field$enableSorting : true
5913 };
5914 });
5915 }
5916
5917 /**
5918 * Apply default values and normalize the fields config.
5919 *
5920 * @param combinedFields combined field list.
5921 * @param fields Fields config.
5922 * @return Normalized fields config.
5923 */
5924 function normalizeCombinedFields(combinedFields, fields) {
5925 return combinedFields.map(combinedField => {
5926 return {
5927 ...combinedField,
5928 Edit: dataform_combined_edit,
5929 fields: normalizeFields(combinedField.children.map(fieldId => fields.find(({
5930 id
5931 }) => id === fieldId)).filter(field => !!field))
5932 };
5933 });
5934 }
5935
5936 ;// ./packages/dataviews/build-module/dataforms-layouts/get-visible-fields.js
5937 /**
5938 * Internal dependencies
5939 */
5940
5941 function getVisibleFields(fields, formFields = [], combinedFields) {
5942 const visibleFields = [...fields];
5943 if (combinedFields) {
5944 visibleFields.push(...normalizeCombinedFields(combinedFields, fields));
5945 }
5946 return formFields.map(fieldId => visibleFields.find(({
5947 id
5948 }) => id === fieldId)).filter(field => !!field);
5949 }
5950
5951 ;// ./packages/dataviews/build-module/dataforms-layouts/regular/index.js
5952 /**
5953 * WordPress dependencies
5954 */
5955
5956
5957
5958 /**
5959 * Internal dependencies
5960 */
5961
5962
5963
5964 function FormRegular({
5965 data,
5966 fields,
5967 form,
5968 onChange
5969 }) {
5970 const visibleFields = (0,external_wp_element_namespaceObject.useMemo)(() => normalizeFields(getVisibleFields(fields, form.fields, form.combinedFields)), [fields, form.fields, form.combinedFields]);
5971 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
5972 spacing: 4,
5973 children: visibleFields.map(field => {
5974 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(field.Edit, {
5975 data: data,
5976 field: field,
5977 onChange: onChange
5978 }, field.id);
5979 })
5980 });
5981 }
5982
5983 ;// ./packages/icons/build-module/library/close-small.js
5984 /**
5985 * WordPress dependencies
5986 */
5987
5988
5989 const closeSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5990 xmlns: "http://www.w3.org/2000/svg",
5991 viewBox: "0 0 24 24",
5992 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5993 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"
5994 })
5995 });
5996 /* harmony default export */ const close_small = (closeSmall);
5997
5998 ;// ./packages/dataviews/build-module/dataforms-layouts/panel/index.js
5999 /**
6000 * WordPress dependencies
6001 */
6002
6003
6004
6005
6006
6007 /**
6008 * Internal dependencies
6009 */
6010
6011
6012
6013 function DropdownHeader({
6014 title,
6015 onClose
6016 }) {
6017 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
6018 className: "dataforms-layouts-panel__dropdown-header",
6019 spacing: 4,
6020 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6021 alignment: "center",
6022 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHeading, {
6023 level: 2,
6024 size: 13,
6025 children: title
6026 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalSpacer, {}), onClose && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6027 label: (0,external_wp_i18n_namespaceObject.__)('Close'),
6028 icon: close_small,
6029 onClick: onClose,
6030 size: "small"
6031 })]
6032 })
6033 });
6034 }
6035 function FormField({
6036 data,
6037 field,
6038 onChange
6039 }) {
6040 // Use internal state instead of a ref to make sure that the component
6041 // re-renders when the popover's anchor updates.
6042 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
6043 // Memoize popoverProps to avoid returning a new object every time.
6044 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
6045 // Anchor the popover to the middle of the entire row so that it doesn't
6046 // move around when the label changes.
6047 anchor: popoverAnchor,
6048 placement: 'left-start',
6049 offset: 36,
6050 shift: true
6051 }), [popoverAnchor]);
6052 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6053 ref: setPopoverAnchor,
6054 className: "dataforms-layouts-panel__field",
6055 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6056 className: "dataforms-layouts-panel__field-label",
6057 children: field.label
6058 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6059 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
6060 contentClassName: "dataforms-layouts-panel__field-dropdown",
6061 popoverProps: popoverProps,
6062 focusOnMount: true,
6063 toggleProps: {
6064 size: 'compact',
6065 variant: 'tertiary',
6066 tooltipPosition: 'middle left'
6067 },
6068 renderToggle: ({
6069 isOpen,
6070 onToggle
6071 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6072 className: "dataforms-layouts-panel__field-control",
6073 size: "compact",
6074 variant: "tertiary",
6075 "aria-expanded": isOpen,
6076 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
6077 // translators: %s: Field name.
6078 (0,external_wp_i18n_namespaceObject._x)('Edit %s', 'field'), field.label),
6079 onClick: onToggle,
6080 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(field.render, {
6081 item: data
6082 })
6083 }),
6084 renderContent: ({
6085 onClose
6086 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6087 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownHeader, {
6088 title: field.label,
6089 onClose: onClose
6090 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(field.Edit, {
6091 data: data,
6092 field: field,
6093 onChange: onChange,
6094 hideLabelFromVision: true
6095 }, field.id)]
6096 })
6097 })
6098 })]
6099 });
6100 }
6101 function FormPanel({
6102 data,
6103 fields,
6104 form,
6105 onChange
6106 }) {
6107 const visibleFields = (0,external_wp_element_namespaceObject.useMemo)(() => normalizeFields(getVisibleFields(fields, form.fields, form.combinedFields)), [fields, form.fields, form.combinedFields]);
6108 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
6109 spacing: 2,
6110 children: visibleFields.map(field => {
6111 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(FormField, {
6112 data: data,
6113 field: field,
6114 onChange: onChange
6115 }, field.id);
6116 })
6117 });
6118 }
6119
6120 ;// ./packages/dataviews/build-module/dataforms-layouts/index.js
6121 /**
6122 * Internal dependencies
6123 */
6124
6125
6126 const FORM_LAYOUTS = [{
6127 type: 'regular',
6128 component: FormRegular
6129 }, {
6130 type: 'panel',
6131 component: FormPanel
6132 }];
6133 function getFormLayout(type) {
6134 return FORM_LAYOUTS.find(layout => layout.type === type);
6135 }
6136
6137 ;// ./packages/dataviews/build-module/components/dataform/index.js
6138 /**
6139 * Internal dependencies
6140 */
6141
6142
6143
6144 function DataForm({
6145 form,
6146 ...props
6147 }) {
6148 var _form$type;
6149 const layout = getFormLayout((_form$type = form.type) !== null && _form$type !== void 0 ? _form$type : 'regular');
6150 if (!layout) {
6151 return null;
6152 }
6153 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(layout.component, {
6154 form: form,
6155 ...props
6156 });
6157 }
6158
6159 ;// ./packages/fields/build-module/actions/utils.js
6160 /**
6161 * WordPress dependencies
6162 */
6163
6164
6165 /**
6166 * Internal dependencies
6167 */
6168
6169 const utils_TEMPLATE_POST_TYPE = 'wp_template';
6170 const utils_TEMPLATE_PART_POST_TYPE = 'wp_template_part';
6171 const utils_TEMPLATE_ORIGINS = {
6172 custom: 'custom',
6173 theme: 'theme',
6174 plugin: 'plugin'
6175 };
6176 function isTemplate(post) {
6177 return post.type === utils_TEMPLATE_POST_TYPE;
6178 }
6179 function isTemplatePart(post) {
6180 return post.type === utils_TEMPLATE_PART_POST_TYPE;
6181 }
6182 function isTemplateOrTemplatePart(p) {
6183 return p.type === utils_TEMPLATE_POST_TYPE || p.type === utils_TEMPLATE_PART_POST_TYPE;
6184 }
6185 function getItemTitle(item) {
6186 if (typeof item.title === 'string') {
6187 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title);
6188 }
6189 if ('rendered' in item.title) {
6190 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.rendered);
6191 }
6192 if ('raw' in item.title) {
6193 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.raw);
6194 }
6195 return '';
6196 }
6197
6198 /**
6199 * Check if a template is removable.
6200 *
6201 * @param template The template entity to check.
6202 * @return Whether the template is removable.
6203 */
6204 function isTemplateRemovable(template) {
6205 if (!template) {
6206 return false;
6207 }
6208 // In patterns list page we map the templates parts to a different object
6209 // than the one returned from the endpoint. This is why we need to check for
6210 // two props whether is custom or has a theme file.
6211 return [template.source, template.source].includes(utils_TEMPLATE_ORIGINS.custom) && !Boolean(template.type === 'wp_template' && template?.plugin) && !template.has_theme_file;
6212 }
6213
6214 ;// ./packages/fields/build-module/fields/title/index.js
6215 /**
6216 * WordPress dependencies
6217 */
6218
6219
6220
6221 /**
6222 * Internal dependencies
6223 */
6224
6225
6226 const titleField = {
6227 type: 'text',
6228 id: 'title',
6229 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
6230 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
6231 getValue: ({
6232 item
6233 }) => getItemTitle(item)
6234 };
6235 /* harmony default export */ const title = (titleField);
6236
6237 ;// ./packages/fields/build-module/actions/duplicate-post.js
6238 /**
6239 * WordPress dependencies
6240 */
6241
6242
6243
6244
6245
6246
6247
6248
6249 /**
6250 * Internal dependencies
6251 */
6252
6253
6254
6255 const fields = [title];
6256 const formDuplicateAction = {
6257 fields: ['title']
6258 };
6259 const duplicatePost = {
6260 id: 'duplicate-post',
6261 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
6262 isEligible({
6263 status
6264 }) {
6265 return status !== 'trash';
6266 },
6267 RenderModal: ({
6268 items,
6269 closeModal,
6270 onActionPerformed
6271 }) => {
6272 const [item, setItem] = (0,external_wp_element_namespaceObject.useState)({
6273 ...items[0],
6274 title: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: Existing template title */
6275 (0,external_wp_i18n_namespaceObject._x)('%s (Copy)', 'template'), getItemTitle(items[0]))
6276 });
6277 const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false);
6278 const {
6279 saveEntityRecord
6280 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
6281 const {
6282 createSuccessNotice,
6283 createErrorNotice
6284 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
6285 async function createPage(event) {
6286 event.preventDefault();
6287 if (isCreatingPage) {
6288 return;
6289 }
6290 const newItemOject = {
6291 status: 'draft',
6292 title: item.title,
6293 slug: item.title || (0,external_wp_i18n_namespaceObject.__)('No title'),
6294 comment_status: item.comment_status,
6295 content: typeof item.content === 'string' ? item.content : item.content.raw,
6296 excerpt: typeof item.excerpt === 'string' ? item.excerpt : item.excerpt?.raw,
6297 meta: item.meta,
6298 parent: item.parent,
6299 password: item.password,
6300 template: item.template,
6301 format: item.format,
6302 featured_media: item.featured_media,
6303 menu_order: item.menu_order,
6304 ping_status: item.ping_status
6305 };
6306 const assignablePropertiesPrefix = 'wp:action-assign-';
6307 // Get all the properties that the current user is able to assign normally author, categories, tags,
6308 // and custom taxonomies.
6309 const assignableProperties = Object.keys(item?._links || {}).filter(property => property.startsWith(assignablePropertiesPrefix)).map(property => property.slice(assignablePropertiesPrefix.length));
6310 assignableProperties.forEach(property => {
6311 if (item.hasOwnProperty(property)) {
6312 // @ts-ignore
6313 newItemOject[property] = item[property];
6314 }
6315 });
6316 setIsCreatingPage(true);
6317 try {
6318 const newItem = await saveEntityRecord('postType', item.type, newItemOject, {
6319 throwOnError: true
6320 });
6321 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
6322 // translators: %s: Title of the created post or template, e.g: "Hello world".
6323 (0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(newItem.title?.rendered || item.title)), {
6324 id: 'duplicate-post-action',
6325 type: 'snackbar'
6326 });
6327 if (onActionPerformed) {
6328 onActionPerformed([newItem]);
6329 }
6330 } catch (error) {
6331 const typedError = error;
6332 const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while duplicating the page.');
6333 createErrorNotice(errorMessage, {
6334 type: 'snackbar'
6335 });
6336 } finally {
6337 setIsCreatingPage(false);
6338 closeModal?.();
6339 }
6340 }
6341 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
6342 onSubmit: createPage,
6343 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
6344 spacing: 3,
6345 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataForm, {
6346 data: item,
6347 fields: fields,
6348 form: formDuplicateAction,
6349 onChange: changes => setItem(prev => ({
6350 ...prev,
6351 ...changes
6352 }))
6353 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6354 spacing: 2,
6355 justify: "end",
6356 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6357 variant: "tertiary",
6358 onClick: closeModal,
6359 __next40pxDefaultSize: true,
6360 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
6361 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6362 variant: "primary",
6363 type: "submit",
6364 isBusy: isCreatingPage,
6365 "aria-disabled": isCreatingPage,
6366 __next40pxDefaultSize: true,
6367 children: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
6368 })]
6369 })]
6370 })
6371 });
6372 }
6373 };
6374 /* harmony default export */ const duplicate_post = (duplicatePost);
6375
6376 ;// external ["wp","patterns"]
6377 const external_wp_patterns_namespaceObject = window["wp"]["patterns"];
6378 ;// ./packages/fields/build-module/lock-unlock.js
6379 /**
6380 * WordPress dependencies
6381 */
6382
6383 const {
6384 lock: lock_unlock_lock,
6385 unlock: lock_unlock_unlock
6386 } = (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');
6387
6388 ;// ./packages/fields/build-module/actions/duplicate-pattern.js
6389 /**
6390 * WordPress dependencies
6391 */
6392
6393 // @ts-ignore
6394
6395 /**
6396 * Internal dependencies
6397 */
6398
6399
6400 // Patterns.
6401 const {
6402 CreatePatternModalContents,
6403 useDuplicatePatternProps
6404 } = lock_unlock_unlock(external_wp_patterns_namespaceObject.privateApis);
6405 const duplicatePattern = {
6406 id: 'duplicate-pattern',
6407 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
6408 isEligible: item => item.type !== 'wp_template_part',
6409 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate pattern', 'action label'),
6410 RenderModal: ({
6411 items,
6412 closeModal
6413 }) => {
6414 const [item] = items;
6415 const duplicatedProps = useDuplicatePatternProps({
6416 pattern: item,
6417 onSuccess: () => closeModal?.()
6418 });
6419 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreatePatternModalContents, {
6420 onClose: closeModal,
6421 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
6422 ...duplicatedProps
6423 });
6424 }
6425 };
6426 /* harmony default export */ const duplicate_pattern = (duplicatePattern);
6427
6428 ;// ./packages/fields/build-module/actions/rename-post.js
6429 /**
6430 * WordPress dependencies
6431 */
6432
6433
6434
6435
6436 // @ts-ignore
6437
6438
6439
6440
6441 /**
6442 * Internal dependencies
6443 */
6444
6445
6446
6447
6448 // Patterns.
6449 const {
6450 PATTERN_TYPES
6451 } = lock_unlock_unlock(external_wp_patterns_namespaceObject.privateApis);
6452 const renamePost = {
6453 id: 'rename-post',
6454 label: (0,external_wp_i18n_namespaceObject.__)('Rename'),
6455 isEligible(post) {
6456 if (post.status === 'trash') {
6457 return false;
6458 }
6459 // Templates, template parts and patterns have special checks for renaming.
6460 if (![utils_TEMPLATE_POST_TYPE, utils_TEMPLATE_PART_POST_TYPE, ...Object.values(PATTERN_TYPES)].includes(post.type)) {
6461 return post.permissions?.update;
6462 }
6463
6464 // In the case of templates, we can only rename custom templates.
6465 if (isTemplate(post)) {
6466 return isTemplateRemovable(post) && post.is_custom && post.permissions?.update;
6467 }
6468 if (isTemplatePart(post)) {
6469 return post.source === utils_TEMPLATE_ORIGINS.custom && !post?.has_theme_file && post.permissions?.update;
6470 }
6471 return post.type === PATTERN_TYPES.user && post.permissions?.update;
6472 },
6473 RenderModal: ({
6474 items,
6475 closeModal,
6476 onActionPerformed
6477 }) => {
6478 const [item] = items;
6479 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => getItemTitle(item));
6480 const {
6481 editEntityRecord,
6482 saveEditedEntityRecord
6483 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
6484 const {
6485 createSuccessNotice,
6486 createErrorNotice
6487 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
6488 async function onRename(event) {
6489 event.preventDefault();
6490 try {
6491 await editEntityRecord('postType', item.type, item.id, {
6492 title
6493 });
6494 // Update state before saving rerenders the list.
6495 setTitle('');
6496 closeModal?.();
6497 // Persist edited entity.
6498 await saveEditedEntityRecord('postType', item.type, item.id, {
6499 throwOnError: true
6500 });
6501 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Name updated'), {
6502 type: 'snackbar'
6503 });
6504 onActionPerformed?.(items);
6505 } catch (error) {
6506 const typedError = error;
6507 const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the name');
6508 createErrorNotice(errorMessage, {
6509 type: 'snackbar'
6510 });
6511 }
6512 }
6513 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
6514 onSubmit: onRename,
6515 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
6516 spacing: "5",
6517 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
6518 __nextHasNoMarginBottom: true,
6519 __next40pxDefaultSize: true,
6520 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
6521 value: title,
6522 onChange: setTitle,
6523 required: true
6524 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6525 justify: "right",
6526 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6527 __next40pxDefaultSize: true,
6528 variant: "tertiary",
6529 onClick: () => {
6530 closeModal?.();
6531 },
6532 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
6533 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6534 __next40pxDefaultSize: true,
6535 variant: "primary",
6536 type: "submit",
6537 children: (0,external_wp_i18n_namespaceObject.__)('Save')
6538 })]
6539 })]
6540 })
6541 });
6542 }
6543 };
6544 /* harmony default export */ const rename_post = (renamePost);
6545
6546 ;// ./packages/dataviews/build-module/validation.js
6547 /**
6548 * Internal dependencies
6549 */
6550
6551 function isItemValid(item, fields, form) {
6552 const _fields = normalizeFields(fields.filter(({
6553 id
6554 }) => !!form.fields?.includes(id)));
6555 return _fields.every(field => {
6556 return field.isValid(item, {
6557 elements: field.elements
6558 });
6559 });
6560 }
6561
6562 ;// ./packages/fields/build-module/fields/order/index.js
6563 /**
6564 * WordPress dependencies
6565 */
6566
6567
6568 /**
6569 * Internal dependencies
6570 */
6571
6572 const orderField = {
6573 type: 'integer',
6574 id: 'menu_order',
6575 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
6576 description: (0,external_wp_i18n_namespaceObject.__)('Determines the order of pages.')
6577 };
6578 /* harmony default export */ const order = (orderField);
6579
6580 ;// ./packages/fields/build-module/actions/reorder-page.js
6581 /**
6582 * WordPress dependencies
6583 */
6584
6585
6586
6587
6588
6589
6590
6591
6592 /**
6593 * Internal dependencies
6594 */
6595
6596
6597
6598 const reorder_page_fields = [order];
6599 const formOrderAction = {
6600 fields: ['menu_order']
6601 };
6602 function ReorderModal({
6603 items,
6604 closeModal,
6605 onActionPerformed
6606 }) {
6607 const [item, setItem] = (0,external_wp_element_namespaceObject.useState)(items[0]);
6608 const orderInput = item.menu_order;
6609 const {
6610 editEntityRecord,
6611 saveEditedEntityRecord
6612 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
6613 const {
6614 createSuccessNotice,
6615 createErrorNotice
6616 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
6617 async function onOrder(event) {
6618 event.preventDefault();
6619 if (!isItemValid(item, reorder_page_fields, formOrderAction)) {
6620 return;
6621 }
6622 try {
6623 await editEntityRecord('postType', item.type, item.id, {
6624 menu_order: orderInput
6625 });
6626 closeModal?.();
6627 // Persist edited entity.
6628 await saveEditedEntityRecord('postType', item.type, item.id, {
6629 throwOnError: true
6630 });
6631 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Order updated.'), {
6632 type: 'snackbar'
6633 });
6634 onActionPerformed?.(items);
6635 } catch (error) {
6636 const typedError = error;
6637 const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the order');
6638 createErrorNotice(errorMessage, {
6639 type: 'snackbar'
6640 });
6641 }
6642 }
6643 const isSaveDisabled = !isItemValid(item, reorder_page_fields, formOrderAction);
6644 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
6645 onSubmit: onOrder,
6646 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
6647 spacing: "5",
6648 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6649 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.')
6650 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataForm, {
6651 data: item,
6652 fields: reorder_page_fields,
6653 form: formOrderAction,
6654 onChange: changes => setItem({
6655 ...item,
6656 ...changes
6657 })
6658 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6659 justify: "right",
6660 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6661 __next40pxDefaultSize: true,
6662 variant: "tertiary",
6663 onClick: () => {
6664 closeModal?.();
6665 },
6666 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
6667 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6668 __next40pxDefaultSize: true,
6669 variant: "primary",
6670 type: "submit",
6671 accessibleWhenDisabled: true,
6672 disabled: isSaveDisabled,
6673 children: (0,external_wp_i18n_namespaceObject.__)('Save')
6674 })]
6675 })]
6676 })
6677 });
6678 }
6679 const reorderPage = {
6680 id: 'order-pages',
6681 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
6682 isEligible({
6683 status
6684 }) {
6685 return status !== 'trash';
6686 },
6687 RenderModal: ReorderModal
6688 };
6689 /* harmony default export */ const reorder_page = (reorderPage);
6690
6691 ;// ./node_modules/tslib/tslib.es6.mjs
6692 /******************************************************************************
6693 Copyright (c) Microsoft Corporation.
6694
6695 Permission to use, copy, modify, and/or distribute this software for any
6696 purpose with or without fee is hereby granted.
6697
6698 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
6699 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6700 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
6701 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6702 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
6703 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6704 PERFORMANCE OF THIS SOFTWARE.
6705 ***************************************************************************** */
6706 /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
6707
6708 var extendStatics = function(d, b) {
6709 extendStatics = Object.setPrototypeOf ||
6710 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6711 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6712 return extendStatics(d, b);
6713 };
6714
6715 function __extends(d, b) {
6716 if (typeof b !== "function" && b !== null)
6717 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6718 extendStatics(d, b);
6719 function __() { this.constructor = d; }
6720 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6721 }
6722
6723 var __assign = function() {
6724 __assign = Object.assign || function __assign(t) {
6725 for (var s, i = 1, n = arguments.length; i < n; i++) {
6726 s = arguments[i];
6727 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6728 }
6729 return t;
6730 }
6731 return __assign.apply(this, arguments);
6732 }
6733
6734 function __rest(s, e) {
6735 var t = {};
6736 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
6737 t[p] = s[p];
6738 if (s != null && typeof Object.getOwnPropertySymbols === "function")
6739 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
6740 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
6741 t[p[i]] = s[p[i]];
6742 }
6743 return t;
6744 }
6745
6746 function __decorate(decorators, target, key, desc) {
6747 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6748 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6749 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;
6750 return c > 3 && r && Object.defineProperty(target, key, r), r;
6751 }
6752
6753 function __param(paramIndex, decorator) {
6754 return function (target, key) { decorator(target, key, paramIndex); }
6755 }
6756
6757 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
6758 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
6759 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
6760 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6761 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6762 var _, done = false;
6763 for (var i = decorators.length - 1; i >= 0; i--) {
6764 var context = {};
6765 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
6766 for (var p in contextIn.access) context.access[p] = contextIn.access[p];
6767 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
6768 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
6769 if (kind === "accessor") {
6770 if (result === void 0) continue;
6771 if (result === null || typeof result !== "object") throw new TypeError("Object expected");
6772 if (_ = accept(result.get)) descriptor.get = _;
6773 if (_ = accept(result.set)) descriptor.set = _;
6774 if (_ = accept(result.init)) initializers.unshift(_);
6775 }
6776 else if (_ = accept(result)) {
6777 if (kind === "field") initializers.unshift(_);
6778 else descriptor[key] = _;
6779 }
6780 }
6781 if (target) Object.defineProperty(target, contextIn.name, descriptor);
6782 done = true;
6783 };
6784
6785 function __runInitializers(thisArg, initializers, value) {
6786 var useValue = arguments.length > 2;
6787 for (var i = 0; i < initializers.length; i++) {
6788 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6789 }
6790 return useValue ? value : void 0;
6791 };
6792
6793 function __propKey(x) {
6794 return typeof x === "symbol" ? x : "".concat(x);
6795 };
6796
6797 function __setFunctionName(f, name, prefix) {
6798 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
6799 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
6800 };
6801
6802 function __metadata(metadataKey, metadataValue) {
6803 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
6804 }
6805
6806 function __awaiter(thisArg, _arguments, P, generator) {
6807 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6808 return new (P || (P = Promise))(function (resolve, reject) {
6809 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6810 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6811 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6812 step((generator = generator.apply(thisArg, _arguments || [])).next());
6813 });
6814 }
6815
6816 function __generator(thisArg, body) {
6817 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);
6818 return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6819 function verb(n) { return function (v) { return step([n, v]); }; }
6820 function step(op) {
6821 if (f) throw new TypeError("Generator is already executing.");
6822 while (g && (g = 0, op[0] && (_ = 0)), _) try {
6823 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;
6824 if (y = 0, t) op = [op[0] & 2, t.value];
6825 switch (op[0]) {
6826 case 0: case 1: t = op; break;
6827 case 4: _.label++; return { value: op[1], done: false };
6828 case 5: _.label++; y = op[1]; op = [0]; continue;
6829 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6830 default:
6831 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6832 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6833 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6834 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6835 if (t[2]) _.ops.pop();
6836 _.trys.pop(); continue;
6837 }
6838 op = body.call(thisArg, _);
6839 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6840 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6841 }
6842 }
6843
6844 var __createBinding = Object.create ? (function(o, m, k, k2) {
6845 if (k2 === undefined) k2 = k;
6846 var desc = Object.getOwnPropertyDescriptor(m, k);
6847 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6848 desc = { enumerable: true, get: function() { return m[k]; } };
6849 }
6850 Object.defineProperty(o, k2, desc);
6851 }) : (function(o, m, k, k2) {
6852 if (k2 === undefined) k2 = k;
6853 o[k2] = m[k];
6854 });
6855
6856 function __exportStar(m, o) {
6857 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
6858 }
6859
6860 function __values(o) {
6861 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
6862 if (m) return m.call(o);
6863 if (o && typeof o.length === "number") return {
6864 next: function () {
6865 if (o && i >= o.length) o = void 0;
6866 return { value: o && o[i++], done: !o };
6867 }
6868 };
6869 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
6870 }
6871
6872 function __read(o, n) {
6873 var m = typeof Symbol === "function" && o[Symbol.iterator];
6874 if (!m) return o;
6875 var i = m.call(o), r, ar = [], e;
6876 try {
6877 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
6878 }
6879 catch (error) { e = { error: error }; }
6880 finally {
6881 try {
6882 if (r && !r.done && (m = i["return"])) m.call(i);
6883 }
6884 finally { if (e) throw e.error; }
6885 }
6886 return ar;
6887 }
6888
6889 /** @deprecated */
6890 function __spread() {
6891 for (var ar = [], i = 0; i < arguments.length; i++)
6892 ar = ar.concat(__read(arguments[i]));
6893 return ar;
6894 }
6895
6896 /** @deprecated */
6897 function __spreadArrays() {
6898 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
6899 for (var r = Array(s), k = 0, i = 0; i < il; i++)
6900 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6901 r[k] = a[j];
6902 return r;
6903 }
6904
6905 function __spreadArray(to, from, pack) {
6906 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
6907 if (ar || !(i in from)) {
6908 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6909 ar[i] = from[i];
6910 }
6911 }
6912 return to.concat(ar || Array.prototype.slice.call(from));
6913 }
6914
6915 function __await(v) {
6916 return this instanceof __await ? (this.v = v, this) : new __await(v);
6917 }
6918
6919 function __asyncGenerator(thisArg, _arguments, generator) {
6920 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
6921 var g = generator.apply(thisArg, _arguments || []), i, q = [];
6922 return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
6923 function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
6924 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]); } }
6925 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
6926 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
6927 function fulfill(value) { resume("next", value); }
6928 function reject(value) { resume("throw", value); }
6929 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
6930 }
6931
6932 function __asyncDelegator(o) {
6933 var i, p;
6934 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
6935 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; }
6936 }
6937
6938 function __asyncValues(o) {
6939 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
6940 var m = o[Symbol.asyncIterator], i;
6941 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);
6942 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); }); }; }
6943 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
6944 }
6945
6946 function __makeTemplateObject(cooked, raw) {
6947 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
6948 return cooked;
6949 };
6950
6951 var __setModuleDefault = Object.create ? (function(o, v) {
6952 Object.defineProperty(o, "default", { enumerable: true, value: v });
6953 }) : function(o, v) {
6954 o["default"] = v;
6955 };
6956
6957 function __importStar(mod) {
6958 if (mod && mod.__esModule) return mod;
6959 var result = {};
6960 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
6961 __setModuleDefault(result, mod);
6962 return result;
6963 }
6964
6965 function __importDefault(mod) {
6966 return (mod && mod.__esModule) ? mod : { default: mod };
6967 }
6968
6969 function __classPrivateFieldGet(receiver, state, kind, f) {
6970 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6971 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");
6972 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6973 }
6974
6975 function __classPrivateFieldSet(receiver, state, value, kind, f) {
6976 if (kind === "m") throw new TypeError("Private method is not writable");
6977 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6978 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");
6979 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6980 }
6981
6982 function __classPrivateFieldIn(state, receiver) {
6983 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
6984 return typeof state === "function" ? receiver === state : state.has(receiver);
6985 }
6986
6987 function __addDisposableResource(env, value, async) {
6988 if (value !== null && value !== void 0) {
6989 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
6990 var dispose, inner;
6991 if (async) {
6992 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
6993 dispose = value[Symbol.asyncDispose];
6994 }
6995 if (dispose === void 0) {
6996 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
6997 dispose = value[Symbol.dispose];
6998 if (async) inner = dispose;
6999 }
7000 if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
7001 if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
7002 env.stack.push({ value: value, dispose: dispose, async: async });
7003 }
7004 else if (async) {
7005 env.stack.push({ async: true });
7006 }
7007 return value;
7008 }
7009
7010 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
7011 var e = new Error(message);
7012 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
7013 };
7014
7015 function __disposeResources(env) {
7016 function fail(e) {
7017 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
7018 env.hasError = true;
7019 }
7020 var r, s = 0;
7021 function next() {
7022 while (r = env.stack.pop()) {
7023 try {
7024 if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
7025 if (r.dispose) {
7026 var result = r.dispose.call(r.value);
7027 if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
7028 }
7029 else s |= 1;
7030 }
7031 catch (e) {
7032 fail(e);
7033 }
7034 }
7035 if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
7036 if (env.hasError) throw env.error;
7037 }
7038 return next();
7039 }
7040
7041 function __rewriteRelativeImportExtension(path, preserveJsx) {
7042 if (typeof path === "string" && /^\.\.?\//.test(path)) {
7043 return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
7044 return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
7045 });
7046 }
7047 return path;
7048 }
7049
7050 /* harmony default export */ const tslib_es6 = ({
7051 __extends,
7052 __assign,
7053 __rest,
7054 __decorate,
7055 __param,
7056 __esDecorate,
7057 __runInitializers,
7058 __propKey,
7059 __setFunctionName,
7060 __metadata,
7061 __awaiter,
7062 __generator,
7063 __createBinding,
7064 __exportStar,
7065 __values,
7066 __read,
7067 __spread,
7068 __spreadArrays,
7069 __spreadArray,
7070 __await,
7071 __asyncGenerator,
7072 __asyncDelegator,
7073 __asyncValues,
7074 __makeTemplateObject,
7075 __importStar,
7076 __importDefault,
7077 __classPrivateFieldGet,
7078 __classPrivateFieldSet,
7079 __classPrivateFieldIn,
7080 __addDisposableResource,
7081 __disposeResources,
7082 __rewriteRelativeImportExtension,
7083 });
7084
7085 ;// ./node_modules/lower-case/dist.es2015/index.js
7086 /**
7087 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
7088 */
7089 var SUPPORTED_LOCALE = {
7090 tr: {
7091 regexp: /\u0130|\u0049|\u0049\u0307/g,
7092 map: {
7093 İ: "\u0069",
7094 I: "\u0131",
7095 İ: "\u0069",
7096 },
7097 },
7098 az: {
7099 regexp: /\u0130/g,
7100 map: {
7101 İ: "\u0069",
7102 I: "\u0131",
7103 İ: "\u0069",
7104 },
7105 },
7106 lt: {
7107 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
7108 map: {
7109 I: "\u0069\u0307",
7110 J: "\u006A\u0307",
7111 Į: "\u012F\u0307",
7112 Ì: "\u0069\u0307\u0300",
7113 Í: "\u0069\u0307\u0301",
7114 Ĩ: "\u0069\u0307\u0303",
7115 },
7116 },
7117 };
7118 /**
7119 * Localized lower case.
7120 */
7121 function localeLowerCase(str, locale) {
7122 var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
7123 if (lang)
7124 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
7125 return lowerCase(str);
7126 }
7127 /**
7128 * Lower case as a function.
7129 */
7130 function lowerCase(str) {
7131 return str.toLowerCase();
7132 }
7133
7134 ;// ./node_modules/no-case/dist.es2015/index.js
7135
7136 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
7137 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
7138 // Remove all non-word characters.
7139 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
7140 /**
7141 * Normalize the string into something other libraries can manipulate easier.
7142 */
7143 function noCase(input, options) {
7144 if (options === void 0) { options = {}; }
7145 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;
7146 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
7147 var start = 0;
7148 var end = result.length;
7149 // Trim the delimiter from around the output string.
7150 while (result.charAt(start) === "\0")
7151 start++;
7152 while (result.charAt(end - 1) === "\0")
7153 end--;
7154 // Transform each token independently.
7155 return result.slice(start, end).split("\0").map(transform).join(delimiter);
7156 }
7157 /**
7158 * Replace `re` in the input string with the replacement value.
7159 */
7160 function replace(input, re, value) {
7161 if (re instanceof RegExp)
7162 return input.replace(re, value);
7163 return re.reduce(function (input, re) { return input.replace(re, value); }, input);
7164 }
7165
7166 ;// ./node_modules/dot-case/dist.es2015/index.js
7167
7168
7169 function dotCase(input, options) {
7170 if (options === void 0) { options = {}; }
7171 return noCase(input, __assign({ delimiter: "." }, options));
7172 }
7173
7174 ;// ./node_modules/param-case/dist.es2015/index.js
7175
7176
7177 function paramCase(input, options) {
7178 if (options === void 0) { options = {}; }
7179 return dotCase(input, __assign({ delimiter: "-" }, options));
7180 }
7181
7182 ;// ./node_modules/client-zip/index.js
7183 "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)),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,r(s),1),l.setUint16(10,r(s),1),l.setUint32(12,i(d),1),l.setUint32(16,i(a),1),yield n(l)}(u,a),u)}
7184 ;// external ["wp","blob"]
7185 const external_wp_blob_namespaceObject = window["wp"]["blob"];
7186 ;// ./packages/icons/build-module/library/download.js
7187 /**
7188 * WordPress dependencies
7189 */
7190
7191
7192 const download = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
7193 xmlns: "http://www.w3.org/2000/svg",
7194 viewBox: "0 0 24 24",
7195 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
7196 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"
7197 })
7198 });
7199 /* harmony default export */ const library_download = (download);
7200
7201 ;// ./packages/fields/build-module/actions/export-pattern.js
7202 /**
7203 * External dependencies
7204 */
7205
7206
7207
7208 /**
7209 * WordPress dependencies
7210 */
7211
7212
7213
7214
7215 /**
7216 * Internal dependencies
7217 */
7218
7219
7220 function getJsonFromItem(item) {
7221 return JSON.stringify({
7222 __file: item.type,
7223 title: getItemTitle(item),
7224 content: typeof item.content === 'string' ? item.content : item.content?.raw,
7225 syncStatus: item.wp_pattern_sync_status
7226 }, null, 2);
7227 }
7228 const exportPattern = {
7229 id: 'export-pattern',
7230 label: (0,external_wp_i18n_namespaceObject.__)('Export as JSON'),
7231 icon: library_download,
7232 supportsBulk: true,
7233 isEligible: item => item.type === 'wp_block',
7234 callback: async items => {
7235 if (items.length === 1) {
7236 return (0,external_wp_blob_namespaceObject.downloadBlob)(`${paramCase(getItemTitle(items[0]) || items[0].slug)}.json`, getJsonFromItem(items[0]), 'application/json');
7237 }
7238 const nameCount = {};
7239 const filesToZip = items.map(item => {
7240 const name = paramCase(getItemTitle(item) || item.slug);
7241 nameCount[name] = (nameCount[name] || 0) + 1;
7242 return {
7243 name: `${name + (nameCount[name] > 1 ? '-' + (nameCount[name] - 1) : '')}.json`,
7244 lastModified: new Date(),
7245 input: getJsonFromItem(item)
7246 };
7247 });
7248 return (0,external_wp_blob_namespaceObject.downloadBlob)((0,external_wp_i18n_namespaceObject.__)('patterns-export') + '.zip', await A(filesToZip).blob(), 'application/zip');
7249 }
7250 };
7251 /* harmony default export */ const export_pattern = (exportPattern);
7252
7253 ;// ./packages/icons/build-module/library/backup.js
7254 /**
7255 * WordPress dependencies
7256 */
7257
7258
7259 const backup = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
7260 xmlns: "http://www.w3.org/2000/svg",
7261 viewBox: "0 0 24 24",
7262 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
7263 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"
7264 })
7265 });
7266 /* harmony default export */ const library_backup = (backup);
7267
7268 ;// ./packages/fields/build-module/actions/restore-post.js
7269 /* wp:polyfill */
7270 /**
7271 * WordPress dependencies
7272 */
7273
7274
7275
7276
7277 /**
7278 * Internal dependencies
7279 */
7280
7281 const restorePost = {
7282 id: 'restore',
7283 label: (0,external_wp_i18n_namespaceObject.__)('Restore'),
7284 isPrimary: true,
7285 icon: library_backup,
7286 supportsBulk: true,
7287 isEligible(item) {
7288 return !isTemplateOrTemplatePart(item) && item.type !== 'wp_block' && item.status === 'trash' && item.permissions?.update;
7289 },
7290 async callback(posts, {
7291 registry,
7292 onActionPerformed
7293 }) {
7294 const {
7295 createSuccessNotice,
7296 createErrorNotice
7297 } = registry.dispatch(external_wp_notices_namespaceObject.store);
7298 const {
7299 editEntityRecord,
7300 saveEditedEntityRecord
7301 } = registry.dispatch(external_wp_coreData_namespaceObject.store);
7302 await Promise.allSettled(posts.map(post => {
7303 return editEntityRecord('postType', post.type, post.id, {
7304 status: 'draft'
7305 });
7306 }));
7307 const promiseResult = await Promise.allSettled(posts.map(post => {
7308 return saveEditedEntityRecord('postType', post.type, post.id, {
7309 throwOnError: true
7310 });
7311 }));
7312 if (promiseResult.every(({
7313 status
7314 }) => status === 'fulfilled')) {
7315 let successMessage;
7316 if (posts.length === 1) {
7317 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of posts. */
7318 (0,external_wp_i18n_namespaceObject.__)('"%s" has been restored.'), getItemTitle(posts[0]));
7319 } else if (posts[0].type === 'page') {
7320 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of posts. */
7321 (0,external_wp_i18n_namespaceObject.__)('%d pages have been restored.'), posts.length);
7322 } else {
7323 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of posts. */
7324 (0,external_wp_i18n_namespaceObject.__)('%d posts have been restored.'), posts.length);
7325 }
7326 createSuccessNotice(successMessage, {
7327 type: 'snackbar',
7328 id: 'restore-post-action'
7329 });
7330 if (onActionPerformed) {
7331 onActionPerformed(posts);
7332 }
7333 } else {
7334 // If there was at lease one failure.
7335 let errorMessage;
7336 // If we were trying to move a single post to the trash.
7337 if (promiseResult.length === 1) {
7338 const typedError = promiseResult[0];
7339 if (typedError.reason?.message) {
7340 errorMessage = typedError.reason.message;
7341 } else {
7342 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the post.');
7343 }
7344 // If we were trying to move multiple posts to the trash
7345 } else {
7346 const errorMessages = new Set();
7347 const failedPromises = promiseResult.filter(({
7348 status
7349 }) => status === 'rejected');
7350 for (const failedPromise of failedPromises) {
7351 const typedError = failedPromise;
7352 if (typedError.reason?.message) {
7353 errorMessages.add(typedError.reason.message);
7354 }
7355 }
7356 if (errorMessages.size === 0) {
7357 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts.');
7358 } else if (errorMessages.size === 1) {
7359 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
7360 (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
7361 } else {
7362 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
7363 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
7364 }
7365 }
7366 createErrorNotice(errorMessage, {
7367 type: 'snackbar'
7368 });
7369 }
7370 }
7371 };
7372 /* harmony default export */ const restore_post = (restorePost);
7373
7374 ;// ./packages/fields/build-module/actions/reset-post.js
7375 /**
7376 * WordPress dependencies
7377 */
7378
7379
7380
7381
7382
7383
7384 // @ts-ignore
7385
7386
7387
7388
7389
7390 /**
7391 * Internal dependencies
7392 */
7393
7394
7395 const reset_post_isTemplateRevertable = templateOrTemplatePart => {
7396 if (!templateOrTemplatePart) {
7397 return false;
7398 }
7399 return templateOrTemplatePart.source === utils_TEMPLATE_ORIGINS.custom && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file);
7400 };
7401
7402 /**
7403 * Copied - pasted from https://github.com/WordPress/gutenberg/blob/bf1462ad37d4637ebbf63270b9c244b23c69e2a8/packages/editor/src/store/private-actions.js#L233-L365
7404 *
7405 * @param {Object} template The template to revert.
7406 * @param {Object} [options]
7407 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
7408 * reverting the template. Default true.
7409 */
7410 const revertTemplate = async (template, {
7411 allowUndo = true
7412 } = {}) => {
7413 const noticeId = 'edit-site-template-reverted';
7414 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).removeNotice(noticeId);
7415 if (!reset_post_isTemplateRevertable(template)) {
7416 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
7417 type: 'snackbar'
7418 });
7419 return;
7420 }
7421 try {
7422 const templateEntityConfig = (0,external_wp_data_namespaceObject.select)(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
7423 if (!templateEntityConfig) {
7424 (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.'), {
7425 type: 'snackbar'
7426 });
7427 return;
7428 }
7429 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
7430 context: 'edit',
7431 source: template.origin
7432 });
7433 const fileTemplate = await external_wp_apiFetch_default()({
7434 path: fileTemplatePath
7435 });
7436 if (!fileTemplate) {
7437 (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.'), {
7438 type: 'snackbar'
7439 });
7440 return;
7441 }
7442 const serializeBlocks = ({
7443 blocks: blocksForSerialization = []
7444 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
7445 const edited = (0,external_wp_data_namespaceObject.select)(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id);
7446
7447 // We are fixing up the undo level here to make sure we can undo
7448 // the revert in the header toolbar correctly.
7449 (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
7450 content: serializeBlocks,
7451 // Required to make the `undo` behave correctly.
7452 blocks: edited.blocks,
7453 // Required to revert the blocks in the editor.
7454 source: 'custom' // required to avoid turning the editor into a dirty state
7455 }, {
7456 undoIgnore: true // Required to merge this edit with the last undo level.
7457 });
7458 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw);
7459 (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
7460 content: serializeBlocks,
7461 blocks,
7462 source: 'theme'
7463 });
7464 if (allowUndo) {
7465 const undoRevert = () => {
7466 (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
7467 content: serializeBlocks,
7468 blocks: edited.blocks,
7469 source: 'custom'
7470 });
7471 };
7472 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reset.'), {
7473 type: 'snackbar',
7474 id: noticeId,
7475 actions: [{
7476 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
7477 onClick: undoRevert
7478 }]
7479 });
7480 }
7481 } catch (error) {
7482 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
7483 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
7484 type: 'snackbar'
7485 });
7486 }
7487 };
7488 const resetPostAction = {
7489 id: 'reset-post',
7490 label: (0,external_wp_i18n_namespaceObject.__)('Reset'),
7491 isEligible: item => {
7492 return isTemplateOrTemplatePart(item) && item?.source === utils_TEMPLATE_ORIGINS.custom && (Boolean(item.type === 'wp_template' && item?.plugin) || item?.has_theme_file);
7493 },
7494 icon: library_backup,
7495 supportsBulk: true,
7496 hideModalHeader: true,
7497 RenderModal: ({
7498 items,
7499 closeModal,
7500 onActionPerformed
7501 }) => {
7502 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
7503 const {
7504 saveEditedEntityRecord
7505 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
7506 const {
7507 createSuccessNotice,
7508 createErrorNotice
7509 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
7510 const onConfirm = async () => {
7511 try {
7512 for (const template of items) {
7513 await revertTemplate(template, {
7514 allowUndo: false
7515 });
7516 await saveEditedEntityRecord('postType', template.type, template.id);
7517 }
7518 createSuccessNotice(items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of items. */
7519 (0,external_wp_i18n_namespaceObject.__)('%s items reset.'), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The template/part's name. */
7520 (0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), getItemTitle(items[0])), {
7521 type: 'snackbar',
7522 id: 'revert-template-action'
7523 });
7524 } catch (error) {
7525 let fallbackErrorMessage;
7526 if (items[0].type === utils_TEMPLATE_POST_TYPE) {
7527 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.');
7528 } else {
7529 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.');
7530 }
7531 const typedError = error;
7532 const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : fallbackErrorMessage;
7533 createErrorNotice(errorMessage, {
7534 type: 'snackbar'
7535 });
7536 }
7537 };
7538 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
7539 spacing: "5",
7540 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
7541 children: (0,external_wp_i18n_namespaceObject.__)('Reset to default and clear all customizations?')
7542 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
7543 justify: "right",
7544 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7545 __next40pxDefaultSize: true,
7546 variant: "tertiary",
7547 onClick: closeModal,
7548 disabled: isBusy,
7549 accessibleWhenDisabled: true,
7550 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
7551 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7552 __next40pxDefaultSize: true,
7553 variant: "primary",
7554 onClick: async () => {
7555 setIsBusy(true);
7556 await onConfirm();
7557 onActionPerformed?.(items);
7558 setIsBusy(false);
7559 closeModal?.();
7560 },
7561 isBusy: isBusy,
7562 disabled: isBusy,
7563 accessibleWhenDisabled: true,
7564 children: (0,external_wp_i18n_namespaceObject.__)('Reset')
7565 })]
7566 })]
7567 });
7568 }
7569 };
7570 /* harmony default export */ const reset_post = (resetPostAction);
7571
7572 ;// ./packages/icons/build-module/library/trash.js
7573 /**
7574 * WordPress dependencies
7575 */
7576
7577
7578 const trash = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
7579 xmlns: "http://www.w3.org/2000/svg",
7580 viewBox: "0 0 24 24",
7581 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
7582 fillRule: "evenodd",
7583 clipRule: "evenodd",
7584 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"
7585 })
7586 });
7587 /* harmony default export */ const library_trash = (trash);
7588
7589 ;// ./packages/fields/build-module/mutation/index.js
7590 /* wp:polyfill */
7591 /**
7592 * WordPress dependencies
7593 */
7594
7595
7596
7597
7598 /**
7599 * Internal dependencies
7600 */
7601
7602 function getErrorMessagesFromPromises(allSettledResults) {
7603 const errorMessages = new Set();
7604 // If there was at lease one failure.
7605 if (allSettledResults.length === 1) {
7606 const typedError = allSettledResults[0];
7607 if (typedError.reason?.message) {
7608 errorMessages.add(typedError.reason.message);
7609 }
7610 } else {
7611 const failedPromises = allSettledResults.filter(({
7612 status
7613 }) => status === 'rejected');
7614 for (const failedPromise of failedPromises) {
7615 const typedError = failedPromise;
7616 if (typedError.reason?.message) {
7617 errorMessages.add(typedError.reason.message);
7618 }
7619 }
7620 }
7621 return errorMessages;
7622 }
7623 const deletePostWithNotices = async (posts, notice, callbacks) => {
7624 const {
7625 createSuccessNotice,
7626 createErrorNotice
7627 } = (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store);
7628 const {
7629 deleteEntityRecord
7630 } = (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store);
7631 const allSettledResults = await Promise.allSettled(posts.map(post => {
7632 return deleteEntityRecord('postType', post.type, post.id, {
7633 force: true
7634 }, {
7635 throwOnError: true
7636 });
7637 }));
7638 // If all the promises were fulfilled with success.
7639 if (allSettledResults.every(({
7640 status
7641 }) => status === 'fulfilled')) {
7642 var _notice$success$type;
7643 let successMessage;
7644 if (allSettledResults.length === 1) {
7645 successMessage = notice.success.messages.getMessage(posts[0]);
7646 } else {
7647 successMessage = notice.success.messages.getBatchMessage(posts);
7648 }
7649 createSuccessNotice(successMessage, {
7650 type: (_notice$success$type = notice.success.type) !== null && _notice$success$type !== void 0 ? _notice$success$type : 'snackbar',
7651 id: notice.success.id
7652 });
7653 callbacks.onActionPerformed?.(posts);
7654 } else {
7655 var _notice$error$type;
7656 const errorMessages = getErrorMessagesFromPromises(allSettledResults);
7657 let errorMessage = '';
7658 if (allSettledResults.length === 1) {
7659 errorMessage = notice.error.messages.getMessage(errorMessages);
7660 } else {
7661 errorMessage = notice.error.messages.getBatchMessage(errorMessages);
7662 }
7663 createErrorNotice(errorMessage, {
7664 type: (_notice$error$type = notice.error.type) !== null && _notice$error$type !== void 0 ? _notice$error$type : 'snackbar',
7665 id: notice.error.id
7666 });
7667 callbacks.onActionError?.();
7668 }
7669 };
7670 const editPostWithNotices = async (postsWithUpdates, notice, callbacks) => {
7671 const {
7672 createSuccessNotice,
7673 createErrorNotice
7674 } = dispatch(noticesStore);
7675 const {
7676 editEntityRecord,
7677 saveEditedEntityRecord
7678 } = dispatch(coreStore);
7679 await Promise.allSettled(postsWithUpdates.map(post => {
7680 return editEntityRecord('postType', post.originalPost.type, post.originalPost.id, {
7681 ...post.changes
7682 });
7683 }));
7684 const allSettledResults = await Promise.allSettled(postsWithUpdates.map(post => {
7685 return saveEditedEntityRecord('postType', post.originalPost.type, post.originalPost.id, {
7686 throwOnError: true
7687 });
7688 }));
7689 // If all the promises were fulfilled with success.
7690 if (allSettledResults.every(({
7691 status
7692 }) => status === 'fulfilled')) {
7693 var _notice$success$type2;
7694 let successMessage;
7695 if (allSettledResults.length === 1) {
7696 successMessage = notice.success.messages.getMessage(postsWithUpdates[0].originalPost);
7697 } else {
7698 successMessage = notice.success.messages.getBatchMessage(postsWithUpdates.map(post => post.originalPost));
7699 }
7700 createSuccessNotice(successMessage, {
7701 type: (_notice$success$type2 = notice.success.type) !== null && _notice$success$type2 !== void 0 ? _notice$success$type2 : 'snackbar',
7702 id: notice.success.id
7703 });
7704 callbacks.onActionPerformed?.(postsWithUpdates.map(post => post.originalPost));
7705 } else {
7706 var _notice$error$type2;
7707 const errorMessages = getErrorMessagesFromPromises(allSettledResults);
7708 let errorMessage = '';
7709 if (allSettledResults.length === 1) {
7710 errorMessage = notice.error.messages.getMessage(errorMessages);
7711 } else {
7712 errorMessage = notice.error.messages.getBatchMessage(errorMessages);
7713 }
7714 createErrorNotice(errorMessage, {
7715 type: (_notice$error$type2 = notice.error.type) !== null && _notice$error$type2 !== void 0 ? _notice$error$type2 : 'snackbar',
7716 id: notice.error.id
7717 });
7718 callbacks.onActionError?.();
7719 }
7720 };
7721
7722 ;// ./packages/fields/build-module/actions/delete-post.js
7723 /**
7724 * WordPress dependencies
7725 */
7726
7727
7728
7729
7730 // @ts-ignore
7731
7732
7733
7734 /**
7735 * Internal dependencies
7736 */
7737
7738
7739
7740
7741 const {
7742 PATTERN_TYPES: delete_post_PATTERN_TYPES
7743 } = lock_unlock_unlock(external_wp_patterns_namespaceObject.privateApis);
7744
7745 // This action is used for templates, patterns and template parts.
7746 // Every other post type uses the similar `trashPostAction` which
7747 // moves the post to trash.
7748 const deletePostAction = {
7749 id: 'delete-post',
7750 label: (0,external_wp_i18n_namespaceObject.__)('Delete'),
7751 isPrimary: true,
7752 icon: library_trash,
7753 isEligible(post) {
7754 if (isTemplateOrTemplatePart(post)) {
7755 return isTemplateRemovable(post);
7756 }
7757 // We can only remove user patterns.
7758 return post.type === delete_post_PATTERN_TYPES.user;
7759 },
7760 supportsBulk: true,
7761 hideModalHeader: true,
7762 RenderModal: ({
7763 items,
7764 closeModal,
7765 onActionPerformed
7766 }) => {
7767 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
7768 const isResetting = items.every(item => isTemplateOrTemplatePart(item) && item?.has_theme_file);
7769 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
7770 spacing: "5",
7771 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
7772 children: items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
7773 // translators: %d: number of items to delete.
7774 (0,external_wp_i18n_namespaceObject._n)('Delete %d item?', 'Delete %d items?', items.length), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)(
7775 // translators: %s: The template or template part's title
7776 (0,external_wp_i18n_namespaceObject._x)('Delete "%s"?', 'template part'), getItemTitle(items[0]))
7777 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
7778 justify: "right",
7779 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7780 variant: "tertiary",
7781 onClick: closeModal,
7782 disabled: isBusy,
7783 accessibleWhenDisabled: true,
7784 __next40pxDefaultSize: true,
7785 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
7786 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7787 variant: "primary",
7788 onClick: async () => {
7789 setIsBusy(true);
7790 const notice = {
7791 success: {
7792 messages: {
7793 getMessage: item => {
7794 return isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The template/part's name. */
7795 (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. */
7796 (0,external_wp_i18n_namespaceObject._x)('"%s" deleted.', 'template part'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(getItemTitle(item)));
7797 },
7798 getBatchMessage: () => {
7799 return isResetting ? (0,external_wp_i18n_namespaceObject.__)('Items reset.') : (0,external_wp_i18n_namespaceObject.__)('Items deleted.');
7800 }
7801 }
7802 },
7803 error: {
7804 messages: {
7805 getMessage: error => {
7806 if (error.size === 1) {
7807 return [...error][0];
7808 }
7809 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.');
7810 },
7811 getBatchMessage: errors => {
7812 if (errors.size === 0) {
7813 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.');
7814 }
7815 if (errors.size === 1) {
7816 return isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
7817 (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 */
7818 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items: %s'), [...errors][0]);
7819 }
7820 return isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
7821 (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 */
7822 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the items: %s'), [...errors].join(','));
7823 }
7824 }
7825 }
7826 };
7827 await deletePostWithNotices(items, notice, {
7828 onActionPerformed
7829 });
7830 setIsBusy(false);
7831 closeModal?.();
7832 },
7833 isBusy: isBusy,
7834 disabled: isBusy,
7835 accessibleWhenDisabled: true,
7836 __next40pxDefaultSize: true,
7837 children: (0,external_wp_i18n_namespaceObject.__)('Delete')
7838 })]
7839 })]
7840 });
7841 }
7842 };
7843 /* harmony default export */ const delete_post = (deletePostAction);
7844
7845 ;// ./packages/fields/build-module/actions/trash-post.js
7846 /* wp:polyfill */
7847 /**
7848 * WordPress dependencies
7849 */
7850
7851
7852
7853
7854
7855
7856
7857 /**
7858 * Internal dependencies
7859 */
7860
7861
7862 const trash_post_trashPost = {
7863 id: 'move-to-trash',
7864 label: (0,external_wp_i18n_namespaceObject.__)('Move to trash'),
7865 isPrimary: true,
7866 icon: library_trash,
7867 isEligible(item) {
7868 if (isTemplateOrTemplatePart(item) || item.type === 'wp_block') {
7869 return false;
7870 }
7871 return !!item.status && !['auto-draft', 'trash'].includes(item.status) && item.permissions?.delete;
7872 },
7873 supportsBulk: true,
7874 hideModalHeader: true,
7875 RenderModal: ({
7876 items,
7877 closeModal,
7878 onActionPerformed
7879 }) => {
7880 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
7881 const {
7882 createSuccessNotice,
7883 createErrorNotice
7884 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
7885 const {
7886 deleteEntityRecord
7887 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
7888 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
7889 spacing: "5",
7890 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
7891 children: items.length === 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
7892 // translators: %s: The item's title.
7893 (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)(
7894 // translators: %d: The number of items (2 or more).
7895 (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)
7896 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
7897 justify: "right",
7898 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7899 __next40pxDefaultSize: true,
7900 variant: "tertiary",
7901 onClick: closeModal,
7902 disabled: isBusy,
7903 accessibleWhenDisabled: true,
7904 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
7905 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7906 __next40pxDefaultSize: true,
7907 variant: "primary",
7908 onClick: async () => {
7909 setIsBusy(true);
7910 const promiseResult = await Promise.allSettled(items.map(item => deleteEntityRecord('postType', item.type, item.id.toString(), {}, {
7911 throwOnError: true
7912 })));
7913 // If all the promises were fulfilled with success.
7914 if (promiseResult.every(({
7915 status
7916 }) => status === 'fulfilled')) {
7917 let successMessage;
7918 if (promiseResult.length === 1) {
7919 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The item's title. */
7920 (0,external_wp_i18n_namespaceObject.__)('"%s" moved to the trash.'), getItemTitle(items[0]));
7921 } else {
7922 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of items. */
7923 (0,external_wp_i18n_namespaceObject._n)('%s item moved to the trash.', '%s items moved to the trash.', items.length), items.length);
7924 }
7925 createSuccessNotice(successMessage, {
7926 type: 'snackbar',
7927 id: 'move-to-trash-action'
7928 });
7929 } else {
7930 // If there was at least one failure.
7931 let errorMessage;
7932 // If we were trying to delete a single item.
7933 if (promiseResult.length === 1) {
7934 const typedError = promiseResult[0];
7935 if (typedError.reason?.message) {
7936 errorMessage = typedError.reason.message;
7937 } else {
7938 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the item to the trash.');
7939 }
7940 // If we were trying to delete multiple items.
7941 } else {
7942 const errorMessages = new Set();
7943 const failedPromises = promiseResult.filter(({
7944 status
7945 }) => status === 'rejected');
7946 for (const failedPromise of failedPromises) {
7947 const typedError = failedPromise;
7948 if (typedError.reason?.message) {
7949 errorMessages.add(typedError.reason.message);
7950 }
7951 }
7952 if (errorMessages.size === 0) {
7953 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the items to the trash.');
7954 } else if (errorMessages.size === 1) {
7955 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
7956 (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the item to the trash: %s'), [...errorMessages][0]);
7957 } else {
7958 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
7959 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while moving the items to the trash: %s'), [...errorMessages].join(','));
7960 }
7961 }
7962 createErrorNotice(errorMessage, {
7963 type: 'snackbar'
7964 });
7965 }
7966 if (onActionPerformed) {
7967 onActionPerformed(items);
7968 }
7969 setIsBusy(false);
7970 closeModal?.();
7971 },
7972 isBusy: isBusy,
7973 disabled: isBusy,
7974 accessibleWhenDisabled: true,
7975 children: (0,external_wp_i18n_namespaceObject._x)('Trash', 'verb')
7976 })]
7977 })]
7978 });
7979 }
7980 };
7981 /* harmony default export */ const trash_post = (trash_post_trashPost);
7982
7983 ;// ./packages/fields/build-module/actions/permanently-delete-post.js
7984 /* wp:polyfill */
7985 /**
7986 * WordPress dependencies
7987 */
7988
7989
7990
7991
7992
7993 /**
7994 * Internal dependencies
7995 */
7996
7997 const permanentlyDeletePost = {
7998 id: 'permanently-delete',
7999 label: (0,external_wp_i18n_namespaceObject.__)('Permanently delete'),
8000 supportsBulk: true,
8001 icon: library_trash,
8002 isEligible(item) {
8003 if (isTemplateOrTemplatePart(item) || item.type === 'wp_block') {
8004 return false;
8005 }
8006 const {
8007 status,
8008 permissions
8009 } = item;
8010 return status === 'trash' && permissions?.delete;
8011 },
8012 async callback(posts, {
8013 registry,
8014 onActionPerformed
8015 }) {
8016 const {
8017 createSuccessNotice,
8018 createErrorNotice
8019 } = registry.dispatch(external_wp_notices_namespaceObject.store);
8020 const {
8021 deleteEntityRecord
8022 } = registry.dispatch(external_wp_coreData_namespaceObject.store);
8023 const promiseResult = await Promise.allSettled(posts.map(post => {
8024 return deleteEntityRecord('postType', post.type, post.id, {
8025 force: true
8026 }, {
8027 throwOnError: true
8028 });
8029 }));
8030 // If all the promises were fulfilled with success.
8031 if (promiseResult.every(({
8032 status
8033 }) => status === 'fulfilled')) {
8034 let successMessage;
8035 if (promiseResult.length === 1) {
8036 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The posts's title. */
8037 (0,external_wp_i18n_namespaceObject.__)('"%s" permanently deleted.'), getItemTitle(posts[0]));
8038 } else {
8039 successMessage = (0,external_wp_i18n_namespaceObject.__)('The items were permanently deleted.');
8040 }
8041 createSuccessNotice(successMessage, {
8042 type: 'snackbar',
8043 id: 'permanently-delete-post-action'
8044 });
8045 onActionPerformed?.(posts);
8046 } else {
8047 // If there was at lease one failure.
8048 let errorMessage;
8049 // If we were trying to permanently delete a single post.
8050 if (promiseResult.length === 1) {
8051 const typedError = promiseResult[0];
8052 if (typedError.reason?.message) {
8053 errorMessage = typedError.reason.message;
8054 } else {
8055 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the item.');
8056 }
8057 // If we were trying to permanently delete multiple posts
8058 } else {
8059 const errorMessages = new Set();
8060 const failedPromises = promiseResult.filter(({
8061 status
8062 }) => status === 'rejected');
8063 for (const failedPromise of failedPromises) {
8064 const typedError = failedPromise;
8065 if (typedError.reason?.message) {
8066 errorMessages.add(typedError.reason.message);
8067 }
8068 }
8069 if (errorMessages.size === 0) {
8070 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the items.');
8071 } else if (errorMessages.size === 1) {
8072 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
8073 (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the items: %s'), [...errorMessages][0]);
8074 } else {
8075 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
8076 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while permanently deleting the items: %s'), [...errorMessages].join(','));
8077 }
8078 }
8079 createErrorNotice(errorMessage, {
8080 type: 'snackbar'
8081 });
8082 }
8083 }
8084 };
8085 /* harmony default export */ const permanently_delete_post = (permanentlyDeletePost);
8086
8087 ;// ./packages/icons/build-module/library/check.js
8088 /**
8089 * WordPress dependencies
8090 */
8091
8092
8093 const check = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8094 xmlns: "http://www.w3.org/2000/svg",
8095 viewBox: "0 0 24 24",
8096 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8097 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
8098 })
8099 });
8100 /* harmony default export */ const library_check = (check);
8101
8102 ;// ./packages/editor/build-module/components/create-template-part-modal/utils.js
8103 /**
8104 * External dependencies
8105 */
8106
8107
8108 /**
8109 * WordPress dependencies
8110 */
8111
8112
8113
8114 /**
8115 * Internal dependencies
8116 */
8117
8118 const useExistingTemplateParts = () => {
8119 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', constants_TEMPLATE_PART_POST_TYPE, {
8120 per_page: -1
8121 }), []);
8122 };
8123
8124 /**
8125 * Return a unique template part title based on
8126 * the given title and existing template parts.
8127 *
8128 * @param {string} title The original template part title.
8129 * @param {Object} templateParts The array of template part entities.
8130 * @return {string} A unique template part title.
8131 */
8132 const getUniqueTemplatePartTitle = (title, templateParts) => {
8133 const lowercaseTitle = title.toLowerCase();
8134 const existingTitles = templateParts.map(templatePart => templatePart.title.rendered.toLowerCase());
8135 if (!existingTitles.includes(lowercaseTitle)) {
8136 return title;
8137 }
8138 let suffix = 2;
8139 while (existingTitles.includes(`${lowercaseTitle} ${suffix}`)) {
8140 suffix++;
8141 }
8142 return `${title} ${suffix}`;
8143 };
8144
8145 /**
8146 * Get a valid slug for a template part.
8147 * Currently template parts only allow latin chars.
8148 * The fallback slug will receive suffix by default.
8149 *
8150 * @param {string} title The template part title.
8151 * @return {string} A valid template part slug.
8152 */
8153 const getCleanTemplatePartSlug = title => {
8154 return paramCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
8155 };
8156
8157 ;// ./packages/editor/build-module/components/create-template-part-modal/index.js
8158 /**
8159 * WordPress dependencies
8160 */
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171 /**
8172 * Internal dependencies
8173 */
8174
8175
8176
8177
8178 function CreateTemplatePartModal({
8179 modalTitle,
8180 ...restProps
8181 }) {
8182 const defaultModalTitle = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(constants_TEMPLATE_PART_POST_TYPE)?.labels?.add_new_item, []);
8183 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
8184 title: modalTitle || defaultModalTitle,
8185 onRequestClose: restProps.closeModal,
8186 overlayClassName: "editor-create-template-part-modal",
8187 focusOnMount: "firstContentElement",
8188 size: "medium",
8189 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
8190 ...restProps
8191 })
8192 });
8193 }
8194 function CreateTemplatePartModalContents({
8195 defaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY,
8196 blocks = [],
8197 confirmLabel = (0,external_wp_i18n_namespaceObject.__)('Add'),
8198 closeModal,
8199 onCreate,
8200 onError,
8201 defaultTitle = ''
8202 }) {
8203 const {
8204 createErrorNotice
8205 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8206 const {
8207 saveEntityRecord
8208 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
8209 const existingTemplateParts = useExistingTemplateParts();
8210 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(defaultTitle);
8211 const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(defaultArea);
8212 const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false);
8213 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal);
8214 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetDefaultTemplatePartAreas(), []);
8215 async function createTemplatePart() {
8216 if (!title || isSubmitting) {
8217 return;
8218 }
8219 try {
8220 setIsSubmitting(true);
8221 const uniqueTitle = getUniqueTemplatePartTitle(title, existingTemplateParts);
8222 const cleanSlug = getCleanTemplatePartSlug(uniqueTitle);
8223 const templatePart = await saveEntityRecord('postType', constants_TEMPLATE_PART_POST_TYPE, {
8224 slug: cleanSlug,
8225 title: uniqueTitle,
8226 content: (0,external_wp_blocks_namespaceObject.serialize)(blocks),
8227 area
8228 }, {
8229 throwOnError: true
8230 });
8231 await onCreate(templatePart);
8232
8233 // TODO: Add a success notice?
8234 } catch (error) {
8235 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.');
8236 createErrorNotice(errorMessage, {
8237 type: 'snackbar'
8238 });
8239 onError?.();
8240 } finally {
8241 setIsSubmitting(false);
8242 }
8243 }
8244 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
8245 onSubmit: async event => {
8246 event.preventDefault();
8247 await createTemplatePart();
8248 },
8249 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
8250 spacing: "4",
8251 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
8252 __next40pxDefaultSize: true,
8253 __nextHasNoMarginBottom: true,
8254 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
8255 value: title,
8256 onChange: setTitle,
8257 required: true
8258 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl, {
8259 __nextHasNoMarginBottom: true,
8260 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
8261 id: `editor-create-template-part-modal__area-selection-${instanceId}`,
8262 className: "editor-create-template-part-modal__area-base-control",
8263 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalRadioGroup, {
8264 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
8265 className: "editor-create-template-part-modal__area-radio-group",
8266 id: `editor-create-template-part-modal__area-selection-${instanceId}`,
8267 onChange: setArea,
8268 checked: area,
8269 children: templatePartAreas.map(({
8270 icon,
8271 label,
8272 area: value,
8273 description
8274 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalRadio, {
8275 value: value,
8276 className: "editor-create-template-part-modal__area-radio",
8277 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
8278 align: "start",
8279 justify: "start",
8280 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
8281 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
8282 icon: icon
8283 })
8284 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.FlexBlock, {
8285 className: "editor-create-template-part-modal__option-label",
8286 children: [label, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
8287 children: description
8288 })]
8289 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
8290 className: "editor-create-template-part-modal__checkbox",
8291 children: area === value && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
8292 icon: library_check
8293 })
8294 })]
8295 })
8296 }, label))
8297 })
8298 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
8299 justify: "right",
8300 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8301 __next40pxDefaultSize: true,
8302 variant: "tertiary",
8303 onClick: () => {
8304 closeModal();
8305 },
8306 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
8307 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8308 __next40pxDefaultSize: true,
8309 variant: "primary",
8310 type: "submit",
8311 "aria-disabled": !title || isSubmitting,
8312 isBusy: isSubmitting,
8313 children: confirmLabel
8314 })]
8315 })]
8316 })
8317 });
8318 }
8319
8320 ;// ./packages/editor/build-module/dataviews/actions/utils.js
8321 /**
8322 * WordPress dependencies
8323 */
8324
8325
8326 /**
8327 * Internal dependencies
8328 */
8329
8330 function utils_isTemplate(post) {
8331 return post.type === TEMPLATE_POST_TYPE;
8332 }
8333 function utils_isTemplatePart(post) {
8334 return post.type === TEMPLATE_PART_POST_TYPE;
8335 }
8336 function utils_isTemplateOrTemplatePart(p) {
8337 return p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE;
8338 }
8339 function utils_getItemTitle(item) {
8340 if (typeof item.title === 'string') {
8341 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title);
8342 }
8343 if ('rendered' in item.title) {
8344 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.rendered);
8345 }
8346 if ('raw' in item.title) {
8347 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.raw);
8348 }
8349 return '';
8350 }
8351
8352 /**
8353 * Check if a template is removable.
8354 *
8355 * @param template The template entity to check.
8356 * @return Whether the template is removable.
8357 */
8358 function utils_isTemplateRemovable(template) {
8359 if (!template) {
8360 return false;
8361 }
8362 // In patterns list page we map the templates parts to a different object
8363 // than the one returned from the endpoint. This is why we need to check for
8364 // two props whether is custom or has a theme file.
8365 return [template.source, template.source].includes(TEMPLATE_ORIGINS.custom) && !Boolean(template.type === 'wp_template' && template?.plugin) && !template.has_theme_file;
8366 }
8367
8368 ;// ./packages/editor/build-module/dataviews/actions/duplicate-template-part.js
8369 /**
8370 * WordPress dependencies
8371 */
8372
8373
8374
8375
8376 // @ts-ignore
8377
8378 /**
8379 * Internal dependencies
8380 */
8381
8382
8383
8384
8385 const duplicateTemplatePart = {
8386 id: 'duplicate-template-part',
8387 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
8388 isEligible: item => item.type === constants_TEMPLATE_PART_POST_TYPE,
8389 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate template part', 'action label'),
8390 RenderModal: ({
8391 items,
8392 closeModal
8393 }) => {
8394 const [item] = items;
8395 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
8396 var _item$blocks;
8397 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, {
8398 __unstableSkipMigrationLogs: true
8399 });
8400 }, [item.content, item.blocks]);
8401 const {
8402 createSuccessNotice
8403 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8404 function onTemplatePartSuccess() {
8405 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
8406 // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
8407 (0,external_wp_i18n_namespaceObject._x)('"%s" duplicated.', 'template part'), utils_getItemTitle(item)), {
8408 type: 'snackbar',
8409 id: 'edit-site-patterns-success'
8410 });
8411 closeModal?.();
8412 }
8413 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
8414 blocks: blocks,
8415 defaultArea: item.area,
8416 defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: Existing template part title */
8417 (0,external_wp_i18n_namespaceObject._x)('%s (Copy)', 'template part'), utils_getItemTitle(item)),
8418 onCreate: onTemplatePartSuccess,
8419 onError: closeModal,
8420 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
8421 closeModal: closeModal
8422 });
8423 }
8424 };
8425 /* harmony default export */ const duplicate_template_part = (duplicateTemplatePart);
8426
8427 ;// ./packages/editor/build-module/dataviews/store/private-actions.js
8428 /**
8429 * WordPress dependencies
8430 */
8431
8432
8433
8434 /**
8435 * Internal dependencies
8436 */
8437
8438
8439
8440
8441
8442 function registerEntityAction(kind, name, config) {
8443 return {
8444 type: 'REGISTER_ENTITY_ACTION',
8445 kind,
8446 name,
8447 config
8448 };
8449 }
8450 function unregisterEntityAction(kind, name, actionId) {
8451 return {
8452 type: 'UNREGISTER_ENTITY_ACTION',
8453 kind,
8454 name,
8455 actionId
8456 };
8457 }
8458 function setIsReady(kind, name) {
8459 return {
8460 type: 'SET_IS_READY',
8461 kind,
8462 name
8463 };
8464 }
8465 const registerPostTypeActions = postType => async ({
8466 registry
8467 }) => {
8468 const isReady = unlock(registry.select(store_store)).isEntityReady('postType', postType);
8469 if (isReady) {
8470 return;
8471 }
8472 unlock(registry.dispatch(store_store)).setIsReady('postType', postType);
8473 const postTypeConfig = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postType);
8474 const canCreate = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).canUser('create', {
8475 kind: 'postType',
8476 name: postType
8477 });
8478 const currentTheme = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getCurrentTheme();
8479 const actions = [postTypeConfig.viewable ? view_post : undefined, !!postTypeConfig?.supports?.revisions ? view_post_revisions : undefined,
8480 // @ts-ignore
8481 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];
8482 registry.batch(() => {
8483 actions.forEach(action => {
8484 if (!action) {
8485 return;
8486 }
8487 unlock(registry.dispatch(store_store)).registerEntityAction('postType', postType, action);
8488 });
8489 });
8490 (0,external_wp_hooks_namespaceObject.doAction)('core.registerPostTypeActions', postType);
8491 };
8492
8493 ;// ./packages/editor/build-module/store/private-actions.js
8494 /* wp:polyfill */
8495 /**
8496 * WordPress dependencies
8497 */
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508 /**
8509 * Internal dependencies
8510 */
8511
8512
8513
8514 /**
8515 * Returns an action object used to set which template is currently being used/edited.
8516 *
8517 * @param {string} id Template Id.
8518 *
8519 * @return {Object} Action object.
8520 */
8521 function setCurrentTemplateId(id) {
8522 return {
8523 type: 'SET_CURRENT_TEMPLATE_ID',
8524 id
8525 };
8526 }
8527
8528 /**
8529 * Create a block based template.
8530 *
8531 * @param {Object?} template Template to create and assign.
8532 */
8533 const createTemplate = template => async ({
8534 select,
8535 dispatch,
8536 registry
8537 }) => {
8538 const savedTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
8539 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', select.getCurrentPostType(), select.getCurrentPostId(), {
8540 template: savedTemplate.slug
8541 });
8542 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)("Custom template created. You're in template mode now."), {
8543 type: 'snackbar',
8544 actions: [{
8545 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
8546 onClick: () => dispatch.setRenderingMode(select.getEditorSettings().defaultRenderingMode)
8547 }]
8548 });
8549 return savedTemplate;
8550 };
8551
8552 /**
8553 * Update the provided block types to be visible.
8554 *
8555 * @param {string[]} blockNames Names of block types to show.
8556 */
8557 const showBlockTypes = blockNames => ({
8558 registry
8559 }) => {
8560 var _registry$select$get;
8561 const existingBlockNames = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
8562 const newBlockNames = existingBlockNames.filter(type => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type));
8563 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', newBlockNames);
8564 };
8565
8566 /**
8567 * Update the provided block types to be hidden.
8568 *
8569 * @param {string[]} blockNames Names of block types to hide.
8570 */
8571 const hideBlockTypes = blockNames => ({
8572 registry
8573 }) => {
8574 var _registry$select$get2;
8575 const existingBlockNames = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
8576 const mergedBlockNames = new Set([...existingBlockNames, ...(Array.isArray(blockNames) ? blockNames : [blockNames])]);
8577 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', [...mergedBlockNames]);
8578 };
8579
8580 /**
8581 * Save entity records marked as dirty.
8582 *
8583 * @param {Object} options Options for the action.
8584 * @param {Function} [options.onSave] Callback when saving happens.
8585 * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.
8586 * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.
8587 * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.
8588 */
8589 const saveDirtyEntities = ({
8590 onSave,
8591 dirtyEntityRecords = [],
8592 entitiesToSkip = [],
8593 close
8594 } = {}) => ({
8595 registry
8596 }) => {
8597 const PUBLISH_ON_SAVE_ENTITIES = [{
8598 kind: 'postType',
8599 name: 'wp_navigation'
8600 }];
8601 const saveNoticeId = 'site-editor-save-success';
8602 const homeUrl = registry.select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.home;
8603 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(saveNoticeId);
8604 const entitiesToSave = dirtyEntityRecords.filter(({
8605 kind,
8606 name,
8607 key,
8608 property
8609 }) => {
8610 return !entitiesToSkip.some(elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
8611 });
8612 close?.(entitiesToSave);
8613 const siteItemsToSave = [];
8614 const pendingSavedRecords = [];
8615 entitiesToSave.forEach(({
8616 kind,
8617 name,
8618 key,
8619 property
8620 }) => {
8621 if ('root' === kind && 'site' === name) {
8622 siteItemsToSave.push(property);
8623 } else {
8624 if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
8625 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord(kind, name, key, {
8626 status: 'publish'
8627 });
8628 }
8629 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord(kind, name, key));
8630 }
8631 });
8632 if (siteItemsToSave.length) {
8633 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalSaveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave));
8634 }
8635 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
8636 Promise.all(pendingSavedRecords).then(values => {
8637 return onSave ? onSave(values) : values;
8638 }).then(values => {
8639 if (values.some(value => typeof value === 'undefined')) {
8640 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.'));
8641 } else {
8642 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), {
8643 type: 'snackbar',
8644 id: saveNoticeId,
8645 actions: [{
8646 label: (0,external_wp_i18n_namespaceObject.__)('View site'),
8647 url: homeUrl
8648 }]
8649 });
8650 }
8651 }).catch(error => registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`));
8652 };
8653
8654 /**
8655 * Reverts a template to its original theme-provided file.
8656 *
8657 * @param {Object} template The template to revert.
8658 * @param {Object} [options]
8659 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
8660 * reverting the template. Default true.
8661 */
8662 const private_actions_revertTemplate = (template, {
8663 allowUndo = true
8664 } = {}) => async ({
8665 registry
8666 }) => {
8667 const noticeId = 'edit-site-template-reverted';
8668 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(noticeId);
8669 if (!isTemplateRevertable(template)) {
8670 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
8671 type: 'snackbar'
8672 });
8673 return;
8674 }
8675 try {
8676 const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
8677 if (!templateEntityConfig) {
8678 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
8679 type: 'snackbar'
8680 });
8681 return;
8682 }
8683 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
8684 context: 'edit',
8685 source: template.origin
8686 });
8687 const fileTemplate = await external_wp_apiFetch_default()({
8688 path: fileTemplatePath
8689 });
8690 if (!fileTemplate) {
8691 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
8692 type: 'snackbar'
8693 });
8694 return;
8695 }
8696 const serializeBlocks = ({
8697 blocks: blocksForSerialization = []
8698 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
8699 const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id);
8700
8701 // We are fixing up the undo level here to make sure we can undo
8702 // the revert in the header toolbar correctly.
8703 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
8704 content: serializeBlocks,
8705 // Required to make the `undo` behave correctly.
8706 blocks: edited.blocks,
8707 // Required to revert the blocks in the editor.
8708 source: 'custom' // required to avoid turning the editor into a dirty state
8709 }, {
8710 undoIgnore: true // Required to merge this edit with the last undo level.
8711 });
8712 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw);
8713 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
8714 content: serializeBlocks,
8715 blocks,
8716 source: 'theme'
8717 });
8718 if (allowUndo) {
8719 const undoRevert = () => {
8720 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
8721 content: serializeBlocks,
8722 blocks: edited.blocks,
8723 source: 'custom'
8724 });
8725 };
8726 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reset.'), {
8727 type: 'snackbar',
8728 id: noticeId,
8729 actions: [{
8730 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
8731 onClick: undoRevert
8732 }]
8733 });
8734 }
8735 } catch (error) {
8736 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
8737 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
8738 type: 'snackbar'
8739 });
8740 }
8741 };
8742
8743 /**
8744 * Action that removes an array of templates, template parts or patterns.
8745 *
8746 * @param {Array} items An array of template,template part or pattern objects to remove.
8747 */
8748 const removeTemplates = items => async ({
8749 registry
8750 }) => {
8751 const isResetting = items.every(item => item?.has_theme_file);
8752 const promiseResult = await Promise.allSettled(items.map(item => {
8753 return registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', item.type, item.id, {
8754 force: true
8755 }, {
8756 throwOnError: true
8757 });
8758 }));
8759
8760 // If all the promises were fulfilled with sucess.
8761 if (promiseResult.every(({
8762 status
8763 }) => status === 'fulfilled')) {
8764 let successMessage;
8765 if (items.length === 1) {
8766 // Depending on how the entity was retrieved its title might be
8767 // an object or simple string.
8768 let title;
8769 if (typeof items[0].title === 'string') {
8770 title = items[0].title;
8771 } else if (typeof items[0].title?.rendered === 'string') {
8772 title = items[0].title?.rendered;
8773 } else if (typeof items[0].title?.raw === 'string') {
8774 title = items[0].title?.raw;
8775 }
8776 successMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The template/part's name. */
8777 (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. */
8778 (0,external_wp_i18n_namespaceObject._x)('"%s" deleted.', 'template part'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
8779 } else {
8780 successMessage = isResetting ? (0,external_wp_i18n_namespaceObject.__)('Items reset.') : (0,external_wp_i18n_namespaceObject.__)('Items deleted.');
8781 }
8782 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(successMessage, {
8783 type: 'snackbar',
8784 id: 'editor-template-deleted-success'
8785 });
8786 } else {
8787 // If there was at lease one failure.
8788 let errorMessage;
8789 // If we were trying to delete a single template.
8790 if (promiseResult.length === 1) {
8791 if (promiseResult[0].reason?.message) {
8792 errorMessage = promiseResult[0].reason.message;
8793 } else {
8794 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.');
8795 }
8796 // If we were trying to delete a multiple templates
8797 } else {
8798 const errorMessages = new Set();
8799 const failedPromises = promiseResult.filter(({
8800 status
8801 }) => status === 'rejected');
8802 for (const failedPromise of failedPromises) {
8803 if (failedPromise.reason?.message) {
8804 errorMessages.add(failedPromise.reason.message);
8805 }
8806 }
8807 if (errorMessages.size === 0) {
8808 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items.');
8809 } else if (errorMessages.size === 1) {
8810 errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
8811 (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 */
8812 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items: %s'), [...errorMessages][0]);
8813 } else {
8814 errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
8815 (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 */
8816 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the items: %s'), [...errorMessages].join(','));
8817 }
8818 }
8819 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
8820 type: 'snackbar'
8821 });
8822 }
8823 };
8824
8825 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/index.js
8826 var fast_deep_equal = __webpack_require__(5215);
8827 var fast_deep_equal_default = /*#__PURE__*/__webpack_require__.n(fast_deep_equal);
8828 ;// ./packages/icons/build-module/library/symbol.js
8829 /**
8830 * WordPress dependencies
8831 */
8832
8833
8834 const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8835 xmlns: "http://www.w3.org/2000/svg",
8836 viewBox: "0 0 24 24",
8837 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8838 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"
8839 })
8840 });
8841 /* harmony default export */ const library_symbol = (symbol);
8842
8843 ;// ./packages/icons/build-module/library/navigation.js
8844 /**
8845 * WordPress dependencies
8846 */
8847
8848
8849 const navigation = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8850 viewBox: "0 0 24 24",
8851 xmlns: "http://www.w3.org/2000/svg",
8852 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8853 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"
8854 })
8855 });
8856 /* harmony default export */ const library_navigation = (navigation);
8857
8858 ;// ./packages/icons/build-module/library/page.js
8859 /**
8860 * WordPress dependencies
8861 */
8862
8863
8864 const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
8865 xmlns: "http://www.w3.org/2000/svg",
8866 viewBox: "0 0 24 24",
8867 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8868 d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"
8869 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8870 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"
8871 })]
8872 });
8873 /* harmony default export */ const library_page = (page);
8874
8875 ;// ./packages/icons/build-module/library/verse.js
8876 /**
8877 * WordPress dependencies
8878 */
8879
8880
8881 const verse = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8882 viewBox: "0 0 24 24",
8883 xmlns: "http://www.w3.org/2000/svg",
8884 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8885 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"
8886 })
8887 });
8888 /* harmony default export */ const library_verse = (verse);
8889
8890 ;// ./packages/editor/build-module/dataviews/store/private-selectors.js
8891 /**
8892 * Internal dependencies
8893 */
8894
8895 const EMPTY_ARRAY = [];
8896 function getEntityActions(state, kind, name) {
8897 var _state$actions$kind$n;
8898 return (_state$actions$kind$n = state.actions[kind]?.[name]) !== null && _state$actions$kind$n !== void 0 ? _state$actions$kind$n : EMPTY_ARRAY;
8899 }
8900 function isEntityReady(state, kind, name) {
8901 return state.isReady[kind]?.[name];
8902 }
8903
8904 ;// ./packages/editor/build-module/store/private-selectors.js
8905 /**
8906 * External dependencies
8907 */
8908
8909
8910 /**
8911 * WordPress dependencies
8912 */
8913
8914
8915
8916
8917
8918 /**
8919 * Internal dependencies
8920 */
8921
8922
8923 const EMPTY_INSERTION_POINT = {
8924 rootClientId: undefined,
8925 insertionIndex: undefined,
8926 filterValue: undefined
8927 };
8928
8929 /**
8930 * Get the inserter.
8931 *
8932 * @param {Object} state Global application state.
8933 *
8934 * @return {Object} The root client ID, index to insert at and starting filter value.
8935 */
8936 const getInserter = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
8937 if (typeof state.blockInserterPanel === 'object') {
8938 return state.blockInserterPanel;
8939 }
8940 if (getRenderingMode(state) === 'template-locked') {
8941 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
8942 if (postContentClientId) {
8943 return {
8944 rootClientId: postContentClientId,
8945 insertionIndex: undefined,
8946 filterValue: undefined
8947 };
8948 }
8949 }
8950 return EMPTY_INSERTION_POINT;
8951 }, state => {
8952 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
8953 return [state.blockInserterPanel, getRenderingMode(state), postContentClientId];
8954 }));
8955 function getListViewToggleRef(state) {
8956 return state.listViewToggleRef;
8957 }
8958 function getInserterSidebarToggleRef(state) {
8959 return state.inserterSidebarToggleRef;
8960 }
8961 const CARD_ICONS = {
8962 wp_block: library_symbol,
8963 wp_navigation: library_navigation,
8964 page: library_page,
8965 post: library_verse
8966 };
8967 const getPostIcon = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, options) => {
8968 {
8969 if (postType === 'wp_template_part' || postType === 'wp_template') {
8970 return __experimentalGetDefaultTemplatePartAreas(state).find(item => options.area === item.area)?.icon || library_layout;
8971 }
8972 if (CARD_ICONS[postType]) {
8973 return CARD_ICONS[postType];
8974 }
8975 const postTypeEntity = select(external_wp_coreData_namespaceObject.store).getPostType(postType);
8976 // `icon` is the `menu_icon` property of a post type. We
8977 // only handle `dashicons` for now, even if the `menu_icon`
8978 // also supports urls and svg as values.
8979 if (typeof postTypeEntity?.icon === 'string' && postTypeEntity.icon.startsWith('dashicons-')) {
8980 return postTypeEntity.icon.slice(10);
8981 }
8982 return library_page;
8983 }
8984 });
8985
8986 /**
8987 * Returns true if there are unsaved changes to the
8988 * post's meta fields, and false otherwise.
8989 *
8990 * @param {Object} state Global application state.
8991 * @param {string} postType The post type of the post.
8992 * @param {number} postId The ID of the post.
8993 *
8994 * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.
8995 */
8996 const hasPostMetaChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
8997 const {
8998 type: currentPostType,
8999 id: currentPostId
9000 } = getCurrentPost(state);
9001 // If no postType or postId is passed, use the current post.
9002 const edits = select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', postType || currentPostType, postId || currentPostId);
9003 if (!edits?.meta) {
9004 return false;
9005 }
9006
9007 // Compare if anything apart from `footnotes` has changed.
9008 const originalPostMeta = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType || currentPostType, postId || currentPostId)?.meta;
9009 return !fast_deep_equal_default()({
9010 ...originalPostMeta,
9011 footnotes: undefined
9012 }, {
9013 ...edits.meta,
9014 footnotes: undefined
9015 });
9016 });
9017 function private_selectors_getEntityActions(state, ...args) {
9018 return getEntityActions(state.dataviews, ...args);
9019 }
9020 function private_selectors_isEntityReady(state, ...args) {
9021 return isEntityReady(state.dataviews, ...args);
9022 }
9023
9024 /**
9025 * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most
9026 * blocks that aren't descendants of the query block.
9027 *
9028 * @param {Object} state Global application state.
9029 * @param {Array|string} blockNames Block names of the blocks to retrieve.
9030 *
9031 * @return {Array} Block client IDs.
9032 */
9033 const getPostBlocksByName = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, blockNames) => {
9034 blockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
9035 const {
9036 getBlocksByName,
9037 getBlockParents,
9038 getBlockName
9039 } = select(external_wp_blockEditor_namespaceObject.store);
9040 return getBlocksByName(blockNames).filter(clientId => getBlockParents(clientId).every(parentClientId => {
9041 const parentBlockName = getBlockName(parentClientId);
9042 return (
9043 // Ignore descendents of the query block.
9044 parentBlockName !== 'core/query' &&
9045 // Enable only the top-most block.
9046 !blockNames.includes(parentBlockName)
9047 );
9048 }));
9049 }, () => [select(external_wp_blockEditor_namespaceObject.store).getBlocks()]));
9050
9051 ;// ./packages/editor/build-module/store/index.js
9052 /**
9053 * WordPress dependencies
9054 */
9055
9056
9057 /**
9058 * Internal dependencies
9059 */
9060
9061
9062
9063
9064
9065
9066
9067
9068 /**
9069 * Post editor data store configuration.
9070 *
9071 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
9072 *
9073 * @type {Object}
9074 */
9075 const storeConfig = {
9076 reducer: store_reducer,
9077 selectors: selectors_namespaceObject,
9078 actions: actions_namespaceObject
9079 };
9080
9081 /**
9082 * Store definition for the editor namespace.
9083 *
9084 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
9085 *
9086 * @type {Object}
9087 */
9088 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
9089 ...storeConfig
9090 });
9091 (0,external_wp_data_namespaceObject.register)(store_store);
9092 unlock(store_store).registerPrivateActions(store_private_actions_namespaceObject);
9093 unlock(store_store).registerPrivateSelectors(store_private_selectors_namespaceObject);
9094
9095 ;// ./packages/editor/build-module/hooks/custom-sources-backwards-compatibility.js
9096 /**
9097 * WordPress dependencies
9098 */
9099
9100
9101
9102
9103
9104
9105 /**
9106 * Internal dependencies
9107 */
9108
9109
9110 /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
9111 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
9112
9113 /**
9114 * Object whose keys are the names of block attributes, where each value
9115 * represents the meta key to which the block attribute is intended to save.
9116 *
9117 * @see https://developer.wordpress.org/reference/functions/register_meta/
9118 *
9119 * @typedef {Object<string,string>} WPMetaAttributeMapping
9120 */
9121
9122 /**
9123 * Given a mapping of attribute names (meta source attributes) to their
9124 * associated meta key, returns a higher order component that overrides its
9125 * `attributes` and `setAttributes` props to sync any changes with the edited
9126 * post's meta keys.
9127 *
9128 * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping.
9129 *
9130 * @return {WPHigherOrderComponent} Higher-order component.
9131 */
9132
9133 const createWithMetaAttributeSource = metaAttributes => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => ({
9134 attributes,
9135 setAttributes,
9136 ...props
9137 }) => {
9138 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
9139 const [meta, setMeta] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', postType, 'meta');
9140 const mergedAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => ({
9141 ...attributes,
9142 ...Object.fromEntries(Object.entries(metaAttributes).map(([attributeKey, metaKey]) => [attributeKey, meta[metaKey]]))
9143 }), [attributes, meta]);
9144 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
9145 attributes: mergedAttributes,
9146 setAttributes: nextAttributes => {
9147 const nextMeta = Object.fromEntries(Object.entries(nextAttributes !== null && nextAttributes !== void 0 ? nextAttributes : {}).filter(
9148 // Filter to intersection of keys between the updated
9149 // attributes and those with an associated meta key.
9150 ([key]) => key in metaAttributes).map(([attributeKey, value]) => [
9151 // Rename the keys to the expected meta key name.
9152 metaAttributes[attributeKey], value]));
9153 if (Object.entries(nextMeta).length) {
9154 setMeta(nextMeta);
9155 }
9156 setAttributes(nextAttributes);
9157 },
9158 ...props
9159 });
9160 }, 'withMetaAttributeSource');
9161
9162 /**
9163 * Filters a registered block's settings to enhance a block's `edit` component
9164 * to upgrade meta-sourced attributes to use the post's meta entity property.
9165 *
9166 * @param {WPBlockSettings} settings Registered block settings.
9167 *
9168 * @return {WPBlockSettings} Filtered block settings.
9169 */
9170 function shimAttributeSource(settings) {
9171 var _settings$attributes;
9172 /** @type {WPMetaAttributeMapping} */
9173 const metaAttributes = Object.fromEntries(Object.entries((_settings$attributes = settings.attributes) !== null && _settings$attributes !== void 0 ? _settings$attributes : {}).filter(([, {
9174 source
9175 }]) => source === 'meta').map(([attributeKey, {
9176 meta
9177 }]) => [attributeKey, meta]));
9178 if (Object.entries(metaAttributes).length) {
9179 settings.edit = createWithMetaAttributeSource(metaAttributes)(settings.edit);
9180 }
9181 return settings;
9182 }
9183 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource);
9184
9185 ;// ./packages/editor/build-module/components/autocompleters/user.js
9186 /**
9187 * WordPress dependencies
9188 */
9189
9190
9191
9192
9193 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
9194
9195 function getUserLabel(user) {
9196 const avatar = user.avatar_urls && user.avatar_urls[24] ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
9197 className: "editor-autocompleters__user-avatar",
9198 alt: "",
9199 src: user.avatar_urls[24]
9200 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9201 className: "editor-autocompleters__no-avatar"
9202 });
9203 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
9204 children: [avatar, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9205 className: "editor-autocompleters__user-name",
9206 children: user.name
9207 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9208 className: "editor-autocompleters__user-slug",
9209 children: user.slug
9210 })]
9211 });
9212 }
9213
9214 /**
9215 * A user mentions completer.
9216 *
9217 * @type {WPCompleter}
9218 */
9219 /* harmony default export */ const user = ({
9220 name: 'users',
9221 className: 'editor-autocompleters__user',
9222 triggerPrefix: '@',
9223 useItems(filterValue) {
9224 const users = (0,external_wp_data_namespaceObject.useSelect)(select => {
9225 const {
9226 getUsers
9227 } = select(external_wp_coreData_namespaceObject.store);
9228 return getUsers({
9229 context: 'view',
9230 search: encodeURIComponent(filterValue)
9231 });
9232 }, [filterValue]);
9233 const options = (0,external_wp_element_namespaceObject.useMemo)(() => users ? users.map(user => ({
9234 key: `user-${user.slug}`,
9235 value: user,
9236 label: getUserLabel(user)
9237 })) : [], [users]);
9238 return [options];
9239 },
9240 getOptionCompletion(user) {
9241 return `@${user.slug}`;
9242 }
9243 });
9244
9245 ;// ./packages/editor/build-module/hooks/default-autocompleters.js
9246 /**
9247 * WordPress dependencies
9248 */
9249
9250
9251 /**
9252 * Internal dependencies
9253 */
9254
9255 function setDefaultCompleters(completers = []) {
9256 // Provide copies so filters may directly modify them.
9257 completers.push({
9258 ...user
9259 });
9260 return completers;
9261 }
9262 (0,external_wp_hooks_namespaceObject.addFilter)('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters);
9263
9264 ;// external ["wp","mediaUtils"]
9265 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
9266 ;// ./packages/editor/build-module/hooks/media-upload.js
9267 /**
9268 * WordPress dependencies
9269 */
9270
9271
9272 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/editor/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload);
9273
9274 ;// ./packages/editor/build-module/hooks/pattern-overrides.js
9275 /**
9276 * WordPress dependencies
9277 */
9278
9279
9280
9281
9282
9283
9284
9285 /**
9286 * Internal dependencies
9287 */
9288
9289
9290
9291 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
9292
9293 const {
9294 PatternOverridesControls,
9295 ResetOverridesControl,
9296 PatternOverridesBlockControls,
9297 PATTERN_TYPES: pattern_overrides_PATTERN_TYPES,
9298 PARTIAL_SYNCING_SUPPORTED_BLOCKS,
9299 PATTERN_SYNC_TYPES
9300 } = unlock(external_wp_patterns_namespaceObject.privateApis);
9301
9302 /**
9303 * Override the default edit UI to include a new block inspector control for
9304 * assigning a partial syncing controls to supported blocks in the pattern editor.
9305 * Currently, only the `core/paragraph` block is supported.
9306 *
9307 * @param {Component} BlockEdit Original component.
9308 *
9309 * @return {Component} Wrapped component.
9310 */
9311 const withPatternOverrideControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
9312 const isSupportedBlock = !!PARTIAL_SYNCING_SUPPORTED_BLOCKS[props.name];
9313 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
9314 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
9315 ...props
9316 }, "edit"), props.isSelected && isSupportedBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ControlsWithStoreSubscription, {
9317 ...props
9318 }), isSupportedBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesBlockControls, {})]
9319 });
9320 }, 'withPatternOverrideControls');
9321
9322 // Split into a separate component to avoid a store subscription
9323 // on every block.
9324 function ControlsWithStoreSubscription(props) {
9325 const blockEditingMode = (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)();
9326 const {
9327 hasPatternOverridesSource,
9328 isEditingSyncedPattern
9329 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9330 const {
9331 getCurrentPostType,
9332 getEditedPostAttribute
9333 } = select(store_store);
9334 return {
9335 // For editing link to the site editor if the theme and user permissions support it.
9336 hasPatternOverridesSource: !!(0,external_wp_blocks_namespaceObject.getBlockBindingsSource)('core/pattern-overrides'),
9337 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
9338 };
9339 }, []);
9340 const bindings = props.attributes.metadata?.bindings;
9341 const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides');
9342 const shouldShowPatternOverridesControls = isEditingSyncedPattern && blockEditingMode === 'default';
9343 const shouldShowResetOverridesControl = !isEditingSyncedPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings;
9344 if (!hasPatternOverridesSource) {
9345 return null;
9346 }
9347 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
9348 children: [shouldShowPatternOverridesControls && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesControls, {
9349 ...props
9350 }), shouldShowResetOverridesControl && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetOverridesControl, {
9351 ...props
9352 })]
9353 });
9354 }
9355 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls);
9356
9357 ;// ./packages/editor/build-module/hooks/index.js
9358 /**
9359 * Internal dependencies
9360 */
9361
9362
9363
9364
9365
9366 ;// external ["wp","keyboardShortcuts"]
9367 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
9368 ;// ./node_modules/clsx/dist/clsx.mjs
9369 function clsx_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=clsx_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=clsx_r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx);
9370 ;// ./packages/icons/build-module/library/star-filled.js
9371 /**
9372 * WordPress dependencies
9373 */
9374
9375
9376 const starFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9377 xmlns: "http://www.w3.org/2000/svg",
9378 viewBox: "0 0 24 24",
9379 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9380 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"
9381 })
9382 });
9383 /* harmony default export */ const star_filled = (starFilled);
9384
9385 ;// ./packages/icons/build-module/library/star-empty.js
9386 /**
9387 * WordPress dependencies
9388 */
9389
9390
9391 const starEmpty = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9392 xmlns: "http://www.w3.org/2000/svg",
9393 viewBox: "0 0 24 24",
9394 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9395 fillRule: "evenodd",
9396 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",
9397 clipRule: "evenodd"
9398 })
9399 });
9400 /* harmony default export */ const star_empty = (starEmpty);
9401
9402 ;// external ["wp","viewport"]
9403 const external_wp_viewport_namespaceObject = window["wp"]["viewport"];
9404 ;// external ["wp","plugins"]
9405 const external_wp_plugins_namespaceObject = window["wp"]["plugins"];
9406 ;// ./packages/interface/build-module/store/deprecated.js
9407 /**
9408 * WordPress dependencies
9409 */
9410
9411 function normalizeComplementaryAreaScope(scope) {
9412 if (['core/edit-post', 'core/edit-site'].includes(scope)) {
9413 external_wp_deprecated_default()(`${scope} interface scope`, {
9414 alternative: 'core interface scope',
9415 hint: 'core/edit-post and core/edit-site are merging.',
9416 version: '6.6'
9417 });
9418 return 'core';
9419 }
9420 return scope;
9421 }
9422 function normalizeComplementaryAreaName(scope, name) {
9423 if (scope === 'core' && name === 'edit-site/template') {
9424 external_wp_deprecated_default()(`edit-site/template sidebar`, {
9425 alternative: 'edit-post/document',
9426 version: '6.6'
9427 });
9428 return 'edit-post/document';
9429 }
9430 if (scope === 'core' && name === 'edit-site/block-inspector') {
9431 external_wp_deprecated_default()(`edit-site/block-inspector sidebar`, {
9432 alternative: 'edit-post/block',
9433 version: '6.6'
9434 });
9435 return 'edit-post/block';
9436 }
9437 return name;
9438 }
9439
9440 ;// ./packages/interface/build-module/store/actions.js
9441 /**
9442 * WordPress dependencies
9443 */
9444
9445
9446
9447 /**
9448 * Internal dependencies
9449 */
9450
9451
9452 /**
9453 * Set a default complementary area.
9454 *
9455 * @param {string} scope Complementary area scope.
9456 * @param {string} area Area identifier.
9457 *
9458 * @return {Object} Action object.
9459 */
9460 const setDefaultComplementaryArea = (scope, area) => {
9461 scope = normalizeComplementaryAreaScope(scope);
9462 area = normalizeComplementaryAreaName(scope, area);
9463 return {
9464 type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
9465 scope,
9466 area
9467 };
9468 };
9469
9470 /**
9471 * Enable the complementary area.
9472 *
9473 * @param {string} scope Complementary area scope.
9474 * @param {string} area Area identifier.
9475 */
9476 const enableComplementaryArea = (scope, area) => ({
9477 registry,
9478 dispatch
9479 }) => {
9480 // Return early if there's no area.
9481 if (!area) {
9482 return;
9483 }
9484 scope = normalizeComplementaryAreaScope(scope);
9485 area = normalizeComplementaryAreaName(scope, area);
9486 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
9487 if (!isComplementaryAreaVisible) {
9488 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true);
9489 }
9490 dispatch({
9491 type: 'ENABLE_COMPLEMENTARY_AREA',
9492 scope,
9493 area
9494 });
9495 };
9496
9497 /**
9498 * Disable the complementary area.
9499 *
9500 * @param {string} scope Complementary area scope.
9501 */
9502 const disableComplementaryArea = scope => ({
9503 registry
9504 }) => {
9505 scope = normalizeComplementaryAreaScope(scope);
9506 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
9507 if (isComplementaryAreaVisible) {
9508 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false);
9509 }
9510 };
9511
9512 /**
9513 * Pins an item.
9514 *
9515 * @param {string} scope Item scope.
9516 * @param {string} item Item identifier.
9517 *
9518 * @return {Object} Action object.
9519 */
9520 const pinItem = (scope, item) => ({
9521 registry
9522 }) => {
9523 // Return early if there's no item.
9524 if (!item) {
9525 return;
9526 }
9527 scope = normalizeComplementaryAreaScope(scope);
9528 item = normalizeComplementaryAreaName(scope, item);
9529 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
9530
9531 // The item is already pinned, there's nothing to do.
9532 if (pinnedItems?.[item] === true) {
9533 return;
9534 }
9535 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
9536 ...pinnedItems,
9537 [item]: true
9538 });
9539 };
9540
9541 /**
9542 * Unpins an item.
9543 *
9544 * @param {string} scope Item scope.
9545 * @param {string} item Item identifier.
9546 */
9547 const unpinItem = (scope, item) => ({
9548 registry
9549 }) => {
9550 // Return early if there's no item.
9551 if (!item) {
9552 return;
9553 }
9554 scope = normalizeComplementaryAreaScope(scope);
9555 item = normalizeComplementaryAreaName(scope, item);
9556 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
9557 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
9558 ...pinnedItems,
9559 [item]: false
9560 });
9561 };
9562
9563 /**
9564 * Returns an action object used in signalling that a feature should be toggled.
9565 *
9566 * @param {string} scope The feature scope (e.g. core/edit-post).
9567 * @param {string} featureName The feature name.
9568 */
9569 function toggleFeature(scope, featureName) {
9570 return function ({
9571 registry
9572 }) {
9573 external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, {
9574 since: '6.0',
9575 alternative: `dispatch( 'core/preferences' ).toggle`
9576 });
9577 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
9578 };
9579 }
9580
9581 /**
9582 * Returns an action object used in signalling that a feature should be set to
9583 * a true or false value
9584 *
9585 * @param {string} scope The feature scope (e.g. core/edit-post).
9586 * @param {string} featureName The feature name.
9587 * @param {boolean} value The value to set.
9588 *
9589 * @return {Object} Action object.
9590 */
9591 function setFeatureValue(scope, featureName, value) {
9592 return function ({
9593 registry
9594 }) {
9595 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, {
9596 since: '6.0',
9597 alternative: `dispatch( 'core/preferences' ).set`
9598 });
9599 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
9600 };
9601 }
9602
9603 /**
9604 * Returns an action object used in signalling that defaults should be set for features.
9605 *
9606 * @param {string} scope The feature scope (e.g. core/edit-post).
9607 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
9608 *
9609 * @return {Object} Action object.
9610 */
9611 function setFeatureDefaults(scope, defaults) {
9612 return function ({
9613 registry
9614 }) {
9615 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, {
9616 since: '6.0',
9617 alternative: `dispatch( 'core/preferences' ).setDefaults`
9618 });
9619 registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
9620 };
9621 }
9622
9623 /**
9624 * Returns an action object used in signalling that the user opened a modal.
9625 *
9626 * @param {string} name A string that uniquely identifies the modal.
9627 *
9628 * @return {Object} Action object.
9629 */
9630 function openModal(name) {
9631 return {
9632 type: 'OPEN_MODAL',
9633 name
9634 };
9635 }
9636
9637 /**
9638 * Returns an action object signalling that the user closed a modal.
9639 *
9640 * @return {Object} Action object.
9641 */
9642 function closeModal() {
9643 return {
9644 type: 'CLOSE_MODAL'
9645 };
9646 }
9647
9648 ;// ./packages/interface/build-module/store/selectors.js
9649 /**
9650 * WordPress dependencies
9651 */
9652
9653
9654
9655
9656 /**
9657 * Internal dependencies
9658 */
9659
9660
9661 /**
9662 * Returns the complementary area that is active in a given scope.
9663 *
9664 * @param {Object} state Global application state.
9665 * @param {string} scope Item scope.
9666 *
9667 * @return {string | null | undefined} The complementary area that is active in the given scope.
9668 */
9669 const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
9670 scope = normalizeComplementaryAreaScope(scope);
9671 const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
9672
9673 // Return `undefined` to indicate that the user has never toggled
9674 // visibility, this is the vanilla default. Other code relies on this
9675 // nuance in the return value.
9676 if (isComplementaryAreaVisible === undefined) {
9677 return undefined;
9678 }
9679
9680 // Return `null` to indicate the user hid the complementary area.
9681 if (isComplementaryAreaVisible === false) {
9682 return null;
9683 }
9684 return state?.complementaryAreas?.[scope];
9685 });
9686 const isComplementaryAreaLoading = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
9687 scope = normalizeComplementaryAreaScope(scope);
9688 const isVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
9689 const identifier = state?.complementaryAreas?.[scope];
9690 return isVisible && identifier === undefined;
9691 });
9692
9693 /**
9694 * Returns a boolean indicating if an item is pinned or not.
9695 *
9696 * @param {Object} state Global application state.
9697 * @param {string} scope Scope.
9698 * @param {string} item Item to check.
9699 *
9700 * @return {boolean} True if the item is pinned and false otherwise.
9701 */
9702 const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
9703 var _pinnedItems$item;
9704 scope = normalizeComplementaryAreaScope(scope);
9705 item = normalizeComplementaryAreaName(scope, item);
9706 const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
9707 return (_pinnedItems$item = pinnedItems?.[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
9708 });
9709
9710 /**
9711 * Returns a boolean indicating whether a feature is active for a particular
9712 * scope.
9713 *
9714 * @param {Object} state The store state.
9715 * @param {string} scope The scope of the feature (e.g. core/edit-post).
9716 * @param {string} featureName The name of the feature.
9717 *
9718 * @return {boolean} Is the feature enabled?
9719 */
9720 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
9721 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
9722 since: '6.0',
9723 alternative: `select( 'core/preferences' ).get( scope, featureName )`
9724 });
9725 return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
9726 });
9727
9728 /**
9729 * Returns true if a modal is active, or false otherwise.
9730 *
9731 * @param {Object} state Global application state.
9732 * @param {string} modalName A string that uniquely identifies the modal.
9733 *
9734 * @return {boolean} Whether the modal is active.
9735 */
9736 function isModalActive(state, modalName) {
9737 return state.activeModal === modalName;
9738 }
9739
9740 ;// ./packages/interface/build-module/store/reducer.js
9741 /**
9742 * WordPress dependencies
9743 */
9744
9745 function complementaryAreas(state = {}, action) {
9746 switch (action.type) {
9747 case 'SET_DEFAULT_COMPLEMENTARY_AREA':
9748 {
9749 const {
9750 scope,
9751 area
9752 } = action;
9753
9754 // If there's already an area, don't overwrite it.
9755 if (state[scope]) {
9756 return state;
9757 }
9758 return {
9759 ...state,
9760 [scope]: area
9761 };
9762 }
9763 case 'ENABLE_COMPLEMENTARY_AREA':
9764 {
9765 const {
9766 scope,
9767 area
9768 } = action;
9769 return {
9770 ...state,
9771 [scope]: area
9772 };
9773 }
9774 }
9775 return state;
9776 }
9777
9778 /**
9779 * Reducer for storing the name of the open modal, or null if no modal is open.
9780 *
9781 * @param {Object} state Previous state.
9782 * @param {Object} action Action object containing the `name` of the modal
9783 *
9784 * @return {Object} Updated state
9785 */
9786 function activeModal(state = null, action) {
9787 switch (action.type) {
9788 case 'OPEN_MODAL':
9789 return action.name;
9790 case 'CLOSE_MODAL':
9791 return null;
9792 }
9793 return state;
9794 }
9795 /* harmony default export */ const build_module_store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
9796 complementaryAreas,
9797 activeModal
9798 }));
9799
9800 ;// ./packages/interface/build-module/store/constants.js
9801 /**
9802 * The identifier for the data store.
9803 *
9804 * @type {string}
9805 */
9806 const constants_STORE_NAME = 'core/interface';
9807
9808 ;// ./packages/interface/build-module/store/index.js
9809 /**
9810 * WordPress dependencies
9811 */
9812
9813
9814 /**
9815 * Internal dependencies
9816 */
9817
9818
9819
9820
9821
9822 /**
9823 * Store definition for the interface namespace.
9824 *
9825 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
9826 *
9827 * @type {Object}
9828 */
9829 const store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, {
9830 reducer: build_module_store_reducer,
9831 actions: store_actions_namespaceObject,
9832 selectors: store_selectors_namespaceObject
9833 });
9834
9835 // Once we build a more generic persistence plugin that works across types of stores
9836 // we'd be able to replace this with a register call.
9837 (0,external_wp_data_namespaceObject.register)(store);
9838
9839 ;// ./packages/interface/build-module/components/complementary-area-toggle/index.js
9840 /**
9841 * WordPress dependencies
9842 */
9843
9844
9845
9846
9847 /**
9848 * Internal dependencies
9849 */
9850
9851
9852 /**
9853 * Whether the role supports checked state.
9854 *
9855 * @param {import('react').AriaRole} role Role.
9856 * @return {boolean} Whether the role supports checked state.
9857 * @see https://www.w3.org/TR/wai-aria-1.1/#aria-checked
9858 */
9859
9860 function roleSupportsCheckedState(role) {
9861 return ['checkbox', 'option', 'radio', 'switch', 'menuitemcheckbox', 'menuitemradio', 'treeitem'].includes(role);
9862 }
9863 function ComplementaryAreaToggle({
9864 as = external_wp_components_namespaceObject.Button,
9865 scope,
9866 identifier: identifierProp,
9867 icon: iconProp,
9868 selectedIcon,
9869 name,
9870 shortcut,
9871 ...props
9872 }) {
9873 const ComponentToUse = as;
9874 const context = (0,external_wp_plugins_namespaceObject.usePluginContext)();
9875 const icon = iconProp || context.icon;
9876 const identifier = identifierProp || `${context.name}/${name}`;
9877 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier, scope]);
9878 const {
9879 enableComplementaryArea,
9880 disableComplementaryArea
9881 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
9882 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComponentToUse, {
9883 icon: selectedIcon && isSelected ? selectedIcon : icon,
9884 "aria-controls": identifier.replace('/', ':')
9885 // Make sure aria-checked matches spec https://www.w3.org/TR/wai-aria-1.1/#aria-checked
9886 ,
9887 "aria-checked": roleSupportsCheckedState(props.role) ? isSelected : undefined,
9888 onClick: () => {
9889 if (isSelected) {
9890 disableComplementaryArea(scope);
9891 } else {
9892 enableComplementaryArea(scope, identifier);
9893 }
9894 },
9895 shortcut: shortcut,
9896 ...props
9897 });
9898 }
9899
9900 ;// ./packages/interface/build-module/components/complementary-area-header/index.js
9901 /**
9902 * External dependencies
9903 */
9904
9905
9906 /**
9907 * WordPress dependencies
9908 */
9909
9910
9911 /**
9912 * Internal dependencies
9913 */
9914
9915
9916 const ComplementaryAreaHeader = ({
9917 children,
9918 className,
9919 toggleButtonProps
9920 }) => {
9921 const toggleButton = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaToggle, {
9922 icon: close_small,
9923 ...toggleButtonProps
9924 });
9925 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9926 className: dist_clsx('components-panel__header', 'interface-complementary-area-header', className),
9927 tabIndex: -1,
9928 children: [children, toggleButton]
9929 });
9930 };
9931 /* harmony default export */ const complementary_area_header = (ComplementaryAreaHeader);
9932
9933 ;// ./packages/interface/build-module/components/action-item/index.js
9934 /**
9935 * WordPress dependencies
9936 */
9937
9938
9939
9940 const noop = () => {};
9941 function ActionItemSlot({
9942 name,
9943 as: Component = external_wp_components_namespaceObject.ButtonGroup,
9944 fillProps = {},
9945 bubblesVirtually,
9946 ...props
9947 }) {
9948 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
9949 name: name,
9950 bubblesVirtually: bubblesVirtually,
9951 fillProps: fillProps,
9952 children: fills => {
9953 if (!external_wp_element_namespaceObject.Children.toArray(fills).length) {
9954 return null;
9955 }
9956
9957 // Special handling exists for backward compatibility.
9958 // It ensures that menu items created by plugin authors aren't
9959 // duplicated with automatically injected menu items coming
9960 // from pinnable plugin sidebars.
9961 // @see https://github.com/WordPress/gutenberg/issues/14457
9962 const initializedByPlugins = [];
9963 external_wp_element_namespaceObject.Children.forEach(fills, ({
9964 props: {
9965 __unstableExplicitMenuItem,
9966 __unstableTarget
9967 }
9968 }) => {
9969 if (__unstableTarget && __unstableExplicitMenuItem) {
9970 initializedByPlugins.push(__unstableTarget);
9971 }
9972 });
9973 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
9974 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
9975 return null;
9976 }
9977 return child;
9978 });
9979 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
9980 ...props,
9981 children: children
9982 });
9983 }
9984 });
9985 }
9986 function ActionItem({
9987 name,
9988 as: Component = external_wp_components_namespaceObject.Button,
9989 onClick,
9990 ...props
9991 }) {
9992 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
9993 name: name,
9994 children: ({
9995 onClick: fpOnClick
9996 }) => {
9997 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
9998 onClick: onClick || fpOnClick ? (...args) => {
9999 (onClick || noop)(...args);
10000 (fpOnClick || noop)(...args);
10001 } : undefined,
10002 ...props
10003 });
10004 }
10005 });
10006 }
10007 ActionItem.Slot = ActionItemSlot;
10008 /* harmony default export */ const action_item = (ActionItem);
10009
10010 ;// ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
10011 /**
10012 * WordPress dependencies
10013 */
10014
10015
10016
10017 /**
10018 * Internal dependencies
10019 */
10020
10021
10022
10023 const PluginsMenuItem = ({
10024 // Menu item is marked with unstable prop for backward compatibility.
10025 // They are removed so they don't leak to DOM elements.
10026 // @see https://github.com/WordPress/gutenberg/issues/14457
10027 __unstableExplicitMenuItem,
10028 __unstableTarget,
10029 ...restProps
10030 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
10031 ...restProps
10032 });
10033 function ComplementaryAreaMoreMenuItem({
10034 scope,
10035 target,
10036 __unstableExplicitMenuItem,
10037 ...props
10038 }) {
10039 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaToggle, {
10040 as: toggleProps => {
10041 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item, {
10042 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
10043 __unstableTarget: `${scope}/${target}`,
10044 as: PluginsMenuItem,
10045 name: `${scope}/plugin-more-menu`,
10046 ...toggleProps
10047 });
10048 },
10049 role: "menuitemcheckbox",
10050 selectedIcon: library_check,
10051 name: target,
10052 scope: scope,
10053 ...props
10054 });
10055 }
10056
10057 ;// ./packages/interface/build-module/components/pinned-items/index.js
10058 /**
10059 * External dependencies
10060 */
10061
10062
10063 /**
10064 * WordPress dependencies
10065 */
10066
10067
10068 function PinnedItems({
10069 scope,
10070 ...props
10071 }) {
10072 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
10073 name: `PinnedItems/${scope}`,
10074 ...props
10075 });
10076 }
10077 function PinnedItemsSlot({
10078 scope,
10079 className,
10080 ...props
10081 }) {
10082 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
10083 name: `PinnedItems/${scope}`,
10084 ...props,
10085 children: fills => fills?.length > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
10086 className: dist_clsx(className, 'interface-pinned-items'),
10087 children: fills
10088 })
10089 });
10090 }
10091 PinnedItems.Slot = PinnedItemsSlot;
10092 /* harmony default export */ const pinned_items = (PinnedItems);
10093
10094 ;// ./packages/interface/build-module/components/complementary-area/index.js
10095 /**
10096 * External dependencies
10097 */
10098
10099
10100 /**
10101 * WordPress dependencies
10102 */
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113 /**
10114 * Internal dependencies
10115 */
10116
10117
10118
10119
10120
10121
10122 const ANIMATION_DURATION = 0.3;
10123 function ComplementaryAreaSlot({
10124 scope,
10125 ...props
10126 }) {
10127 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
10128 name: `ComplementaryArea/${scope}`,
10129 ...props
10130 });
10131 }
10132 const SIDEBAR_WIDTH = 280;
10133 const variants = {
10134 open: {
10135 width: SIDEBAR_WIDTH
10136 },
10137 closed: {
10138 width: 0
10139 },
10140 mobileOpen: {
10141 width: '100vw'
10142 }
10143 };
10144 function ComplementaryAreaFill({
10145 activeArea,
10146 isActive,
10147 scope,
10148 children,
10149 className,
10150 id
10151 }) {
10152 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
10153 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
10154 // This is used to delay the exit animation to the next tick.
10155 // The reason this is done is to allow us to apply the right transition properties
10156 // When we switch from an open sidebar to another open sidebar.
10157 // we don't want to animate in this case.
10158 const previousActiveArea = (0,external_wp_compose_namespaceObject.usePrevious)(activeArea);
10159 const previousIsActive = (0,external_wp_compose_namespaceObject.usePrevious)(isActive);
10160 const [, setState] = (0,external_wp_element_namespaceObject.useState)({});
10161 (0,external_wp_element_namespaceObject.useEffect)(() => {
10162 setState({});
10163 }, [isActive]);
10164 const transition = {
10165 type: 'tween',
10166 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION,
10167 ease: [0.6, 0, 0.4, 1]
10168 };
10169 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
10170 name: `ComplementaryArea/${scope}`,
10171 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
10172 initial: false,
10173 children: (previousIsActive || isActive) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
10174 variants: variants,
10175 initial: "closed",
10176 animate: isMobileViewport ? 'mobileOpen' : 'open',
10177 exit: "closed",
10178 transition: transition,
10179 className: "interface-complementary-area__fill",
10180 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
10181 id: id,
10182 className: className,
10183 style: {
10184 width: isMobileViewport ? '100vw' : SIDEBAR_WIDTH
10185 },
10186 children: children
10187 })
10188 })
10189 })
10190 });
10191 }
10192 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
10193 const previousIsSmallRef = (0,external_wp_element_namespaceObject.useRef)(false);
10194 const shouldOpenWhenNotSmallRef = (0,external_wp_element_namespaceObject.useRef)(false);
10195 const {
10196 enableComplementaryArea,
10197 disableComplementaryArea
10198 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
10199 (0,external_wp_element_namespaceObject.useEffect)(() => {
10200 // If the complementary area is active and the editor is switching from
10201 // a big to a small window size.
10202 if (isActive && isSmall && !previousIsSmallRef.current) {
10203 disableComplementaryArea(scope);
10204 // Flag the complementary area to be reopened when the window size
10205 // goes from small to big.
10206 shouldOpenWhenNotSmallRef.current = true;
10207 } else if (
10208 // If there is a flag indicating the complementary area should be
10209 // enabled when we go from small to big window size and we are going
10210 // from a small to big window size.
10211 shouldOpenWhenNotSmallRef.current && !isSmall && previousIsSmallRef.current) {
10212 // Remove the flag indicating the complementary area should be
10213 // enabled.
10214 shouldOpenWhenNotSmallRef.current = false;
10215 enableComplementaryArea(scope, identifier);
10216 } else if (
10217 // If the flag is indicating the current complementary should be
10218 // reopened but another complementary area becomes active, remove
10219 // the flag.
10220 shouldOpenWhenNotSmallRef.current && activeArea && activeArea !== identifier) {
10221 shouldOpenWhenNotSmallRef.current = false;
10222 }
10223 if (isSmall !== previousIsSmallRef.current) {
10224 previousIsSmallRef.current = isSmall;
10225 }
10226 }, [isActive, isSmall, scope, identifier, activeArea, disableComplementaryArea, enableComplementaryArea]);
10227 }
10228 function ComplementaryArea({
10229 children,
10230 className,
10231 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
10232 identifier: identifierProp,
10233 header,
10234 headerClassName,
10235 icon: iconProp,
10236 isPinnable = true,
10237 panelClassName,
10238 scope,
10239 name,
10240 title,
10241 toggleShortcut,
10242 isActiveByDefault
10243 }) {
10244 const context = (0,external_wp_plugins_namespaceObject.usePluginContext)();
10245 const icon = iconProp || context.icon;
10246 const identifier = identifierProp || `${context.name}/${name}`;
10247
10248 // This state is used to delay the rendering of the Fill
10249 // until the initial effect runs.
10250 // This prevents the animation from running on mount if
10251 // the complementary area is active by default.
10252 const [isReady, setIsReady] = (0,external_wp_element_namespaceObject.useState)(false);
10253 const {
10254 isLoading,
10255 isActive,
10256 isPinned,
10257 activeArea,
10258 isSmall,
10259 isLarge,
10260 showIconLabels
10261 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10262 const {
10263 getActiveComplementaryArea,
10264 isComplementaryAreaLoading,
10265 isItemPinned
10266 } = select(store);
10267 const {
10268 get
10269 } = select(external_wp_preferences_namespaceObject.store);
10270 const _activeArea = getActiveComplementaryArea(scope);
10271 return {
10272 isLoading: isComplementaryAreaLoading(scope),
10273 isActive: _activeArea === identifier,
10274 isPinned: isItemPinned(scope, identifier),
10275 activeArea: _activeArea,
10276 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
10277 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large'),
10278 showIconLabels: get('core', 'showIconLabels')
10279 };
10280 }, [identifier, scope]);
10281 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
10282 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
10283 const {
10284 enableComplementaryArea,
10285 disableComplementaryArea,
10286 pinItem,
10287 unpinItem
10288 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
10289 (0,external_wp_element_namespaceObject.useEffect)(() => {
10290 // Set initial visibility: For large screens, enable if it's active by
10291 // default. For small screens, always initially disable.
10292 if (isActiveByDefault && activeArea === undefined && !isSmall) {
10293 enableComplementaryArea(scope, identifier);
10294 } else if (activeArea === undefined && isSmall) {
10295 disableComplementaryArea(scope, identifier);
10296 }
10297 setIsReady(true);
10298 }, [activeArea, isActiveByDefault, scope, identifier, isSmall, enableComplementaryArea, disableComplementaryArea]);
10299 if (!isReady) {
10300 return;
10301 }
10302 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
10303 children: [isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items, {
10304 scope: scope,
10305 children: isPinned && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaToggle, {
10306 scope: scope,
10307 identifier: identifier,
10308 isPressed: isActive && (!showIconLabels || isLarge),
10309 "aria-expanded": isActive,
10310 "aria-disabled": isLoading,
10311 label: title,
10312 icon: showIconLabels ? library_check : icon,
10313 showTooltip: !showIconLabels,
10314 variant: showIconLabels ? 'tertiary' : undefined,
10315 size: "compact",
10316 shortcut: toggleShortcut
10317 })
10318 }), name && isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem, {
10319 target: name,
10320 scope: scope,
10321 icon: icon,
10322 children: title
10323 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ComplementaryAreaFill, {
10324 activeArea: activeArea,
10325 isActive: isActive,
10326 className: dist_clsx('interface-complementary-area', className),
10327 scope: scope,
10328 id: identifier.replace('/', ':'),
10329 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_header, {
10330 className: headerClassName,
10331 closeLabel: closeLabel,
10332 onClose: () => disableComplementaryArea(scope),
10333 toggleButtonProps: {
10334 label: closeLabel,
10335 size: 'small',
10336 shortcut: toggleShortcut,
10337 scope,
10338 identifier
10339 },
10340 children: header || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
10341 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
10342 className: "interface-complementary-area-header__title",
10343 children: title
10344 }), isPinnable && !isMobileViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10345 className: "interface-complementary-area__pin-unpin-item",
10346 icon: isPinned ? star_filled : star_empty,
10347 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
10348 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
10349 isPressed: isPinned,
10350 "aria-expanded": isPinned,
10351 size: "compact"
10352 })]
10353 })
10354 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Panel, {
10355 className: panelClassName,
10356 children: children
10357 })]
10358 })]
10359 });
10360 }
10361 ComplementaryArea.Slot = ComplementaryAreaSlot;
10362 /* harmony default export */ const complementary_area = (ComplementaryArea);
10363
10364 ;// ./packages/interface/build-module/components/fullscreen-mode/index.js
10365 /**
10366 * WordPress dependencies
10367 */
10368
10369 const FullscreenMode = ({
10370 isActive
10371 }) => {
10372 (0,external_wp_element_namespaceObject.useEffect)(() => {
10373 let isSticky = false;
10374 // `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes
10375 // `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled
10376 // even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as
10377 // a consequence of the FullscreenMode setup.
10378 if (document.body.classList.contains('sticky-menu')) {
10379 isSticky = true;
10380 document.body.classList.remove('sticky-menu');
10381 }
10382 return () => {
10383 if (isSticky) {
10384 document.body.classList.add('sticky-menu');
10385 }
10386 };
10387 }, []);
10388 (0,external_wp_element_namespaceObject.useEffect)(() => {
10389 if (isActive) {
10390 document.body.classList.add('is-fullscreen-mode');
10391 } else {
10392 document.body.classList.remove('is-fullscreen-mode');
10393 }
10394 return () => {
10395 if (isActive) {
10396 document.body.classList.remove('is-fullscreen-mode');
10397 }
10398 };
10399 }, [isActive]);
10400 return null;
10401 };
10402 /* harmony default export */ const fullscreen_mode = (FullscreenMode);
10403
10404 ;// ./packages/interface/build-module/components/navigable-region/index.js
10405 /**
10406 * WordPress dependencies
10407 */
10408
10409
10410 /**
10411 * External dependencies
10412 */
10413
10414
10415 const NavigableRegion = (0,external_wp_element_namespaceObject.forwardRef)(({
10416 children,
10417 className,
10418 ariaLabel,
10419 as: Tag = 'div',
10420 ...props
10421 }, ref) => {
10422 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tag, {
10423 ref: ref,
10424 className: dist_clsx('interface-navigable-region', className),
10425 "aria-label": ariaLabel,
10426 role: "region",
10427 tabIndex: "-1",
10428 ...props,
10429 children: children
10430 });
10431 });
10432 NavigableRegion.displayName = 'NavigableRegion';
10433 /* harmony default export */ const navigable_region = (NavigableRegion);
10434
10435 ;// ./packages/interface/build-module/components/interface-skeleton/index.js
10436 /**
10437 * External dependencies
10438 */
10439
10440
10441 /**
10442 * WordPress dependencies
10443 */
10444
10445
10446
10447
10448
10449 /**
10450 * Internal dependencies
10451 */
10452
10453
10454 const interface_skeleton_ANIMATION_DURATION = 0.25;
10455 const commonTransition = {
10456 type: 'tween',
10457 duration: interface_skeleton_ANIMATION_DURATION,
10458 ease: [0.6, 0, 0.4, 1]
10459 };
10460 function useHTMLClass(className) {
10461 (0,external_wp_element_namespaceObject.useEffect)(() => {
10462 const element = document && document.querySelector(`html:not(.${className})`);
10463 if (!element) {
10464 return;
10465 }
10466 element.classList.toggle(className);
10467 return () => {
10468 element.classList.toggle(className);
10469 };
10470 }, [className]);
10471 }
10472 const headerVariants = {
10473 hidden: {
10474 opacity: 1,
10475 marginTop: -60
10476 },
10477 visible: {
10478 opacity: 1,
10479 marginTop: 0
10480 },
10481 distractionFreeHover: {
10482 opacity: 1,
10483 marginTop: 0,
10484 transition: {
10485 ...commonTransition,
10486 delay: 0.2,
10487 delayChildren: 0.2
10488 }
10489 },
10490 distractionFreeHidden: {
10491 opacity: 0,
10492 marginTop: -60
10493 },
10494 distractionFreeDisabled: {
10495 opacity: 0,
10496 marginTop: 0,
10497 transition: {
10498 ...commonTransition,
10499 delay: 0.8,
10500 delayChildren: 0.8
10501 }
10502 }
10503 };
10504 function InterfaceSkeleton({
10505 isDistractionFree,
10506 footer,
10507 header,
10508 editorNotices,
10509 sidebar,
10510 secondarySidebar,
10511 content,
10512 actions,
10513 labels,
10514 className
10515 }, ref) {
10516 const [secondarySidebarResizeListener, secondarySidebarSize] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
10517 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
10518 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
10519 const defaultTransition = {
10520 type: 'tween',
10521 duration: disableMotion ? 0 : interface_skeleton_ANIMATION_DURATION,
10522 ease: [0.6, 0, 0.4, 1]
10523 };
10524 useHTMLClass('interface-interface-skeleton__html-container');
10525 const defaultLabels = {
10526 /* translators: accessibility text for the top bar landmark region. */
10527 header: (0,external_wp_i18n_namespaceObject._x)('Header', 'header landmark area'),
10528 /* translators: accessibility text for the content landmark region. */
10529 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
10530 /* translators: accessibility text for the secondary sidebar landmark region. */
10531 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
10532 /* translators: accessibility text for the settings landmark region. */
10533 sidebar: (0,external_wp_i18n_namespaceObject._x)('Settings', 'settings landmark area'),
10534 /* translators: accessibility text for the publish landmark region. */
10535 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
10536 /* translators: accessibility text for the footer landmark region. */
10537 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
10538 };
10539 const mergedLabels = {
10540 ...defaultLabels,
10541 ...labels
10542 };
10543 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10544 ref: ref,
10545 className: dist_clsx(className, 'interface-interface-skeleton', !!footer && 'has-footer'),
10546 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10547 className: "interface-interface-skeleton__editor",
10548 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
10549 initial: false,
10550 children: !!header && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
10551 as: external_wp_components_namespaceObject.__unstableMotion.div,
10552 className: "interface-interface-skeleton__header",
10553 "aria-label": mergedLabels.header,
10554 initial: isDistractionFree && !isMobileViewport ? 'distractionFreeHidden' : 'hidden',
10555 whileHover: isDistractionFree && !isMobileViewport ? 'distractionFreeHover' : 'visible',
10556 animate: isDistractionFree && !isMobileViewport ? 'distractionFreeDisabled' : 'visible',
10557 exit: isDistractionFree && !isMobileViewport ? 'distractionFreeHidden' : 'hidden',
10558 variants: headerVariants,
10559 transition: defaultTransition,
10560 children: header
10561 })
10562 }), isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
10563 className: "interface-interface-skeleton__header",
10564 children: editorNotices
10565 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10566 className: "interface-interface-skeleton__body",
10567 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
10568 initial: false,
10569 children: !!secondarySidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
10570 className: "interface-interface-skeleton__secondary-sidebar",
10571 ariaLabel: mergedLabels.secondarySidebar,
10572 as: external_wp_components_namespaceObject.__unstableMotion.div,
10573 initial: "closed",
10574 animate: "open",
10575 exit: "closed",
10576 variants: {
10577 open: {
10578 width: secondarySidebarSize.width
10579 },
10580 closed: {
10581 width: 0
10582 }
10583 },
10584 transition: defaultTransition,
10585 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
10586 style: {
10587 position: 'absolute',
10588 width: isMobileViewport ? '100vw' : 'fit-content',
10589 height: '100%',
10590 left: 0
10591 },
10592 variants: {
10593 open: {
10594 x: 0
10595 },
10596 closed: {
10597 x: '-100%'
10598 }
10599 },
10600 transition: defaultTransition,
10601 children: [secondarySidebarResizeListener, secondarySidebar]
10602 })
10603 })
10604 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
10605 className: "interface-interface-skeleton__content",
10606 ariaLabel: mergedLabels.body,
10607 children: content
10608 }), !!sidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
10609 className: "interface-interface-skeleton__sidebar",
10610 ariaLabel: mergedLabels.sidebar,
10611 children: sidebar
10612 }), !!actions && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
10613 className: "interface-interface-skeleton__actions",
10614 ariaLabel: mergedLabels.actions,
10615 children: actions
10616 })]
10617 })]
10618 }), !!footer && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
10619 className: "interface-interface-skeleton__footer",
10620 ariaLabel: mergedLabels.footer,
10621 children: footer
10622 })]
10623 });
10624 }
10625 /* harmony default export */ const interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
10626
10627 ;// ./packages/interface/build-module/components/index.js
10628
10629
10630
10631
10632
10633
10634
10635
10636 ;// ./packages/interface/build-module/index.js
10637
10638
10639
10640 ;// ./packages/editor/build-module/components/global-keyboard-shortcuts/index.js
10641 /**
10642 * WordPress dependencies
10643 */
10644
10645
10646
10647
10648
10649 /**
10650 * Internal dependencies
10651 */
10652
10653
10654 /**
10655 * Handles the keyboard shortcuts for the editor.
10656 *
10657 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
10658 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
10659 * and toggling the sidebar.
10660 */
10661 function EditorKeyboardShortcuts() {
10662 const isModeToggleDisabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
10663 const {
10664 richEditingEnabled,
10665 codeEditingEnabled
10666 } = select(store_store).getEditorSettings();
10667 return !richEditingEnabled || !codeEditingEnabled;
10668 }, []);
10669 const {
10670 getBlockSelectionStart
10671 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
10672 const {
10673 getActiveComplementaryArea
10674 } = (0,external_wp_data_namespaceObject.useSelect)(store);
10675 const {
10676 enableComplementaryArea,
10677 disableComplementaryArea
10678 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
10679 const {
10680 redo,
10681 undo,
10682 savePost,
10683 setIsListViewOpened,
10684 switchEditorMode,
10685 toggleDistractionFree
10686 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10687 const {
10688 isEditedPostDirty,
10689 isPostSavingLocked,
10690 isListViewOpened,
10691 getEditorMode
10692 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
10693 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-mode', () => {
10694 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
10695 }, {
10696 isDisabled: isModeToggleDisabled
10697 });
10698 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-distraction-free', () => {
10699 toggleDistractionFree();
10700 });
10701 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/undo', event => {
10702 undo();
10703 event.preventDefault();
10704 });
10705 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/redo', event => {
10706 redo();
10707 event.preventDefault();
10708 });
10709 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/save', event => {
10710 event.preventDefault();
10711
10712 /**
10713 * Do not save the post if post saving is locked.
10714 */
10715 if (isPostSavingLocked()) {
10716 return;
10717 }
10718
10719 // TODO: This should be handled in the `savePost` effect in
10720 // considering `isSaveable`. See note on `isEditedPostSaveable`
10721 // selector about dirtiness and meta-boxes.
10722 //
10723 // See: `isEditedPostSaveable`
10724 if (!isEditedPostDirty()) {
10725 return;
10726 }
10727 savePost();
10728 });
10729
10730 // Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.
10731 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', event => {
10732 if (!isListViewOpened()) {
10733 event.preventDefault();
10734 setIsListViewOpened(true);
10735 }
10736 });
10737 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-sidebar', event => {
10738 // This shortcut has no known clashes, but use preventDefault to prevent any
10739 // obscure shortcuts from triggering.
10740 event.preventDefault();
10741 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(getActiveComplementaryArea('core'));
10742 if (isEditorSidebarOpened) {
10743 disableComplementaryArea('core');
10744 } else {
10745 const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document';
10746 enableComplementaryArea('core', sidebarToOpen);
10747 }
10748 });
10749 return null;
10750 }
10751
10752 ;// ./packages/editor/build-module/components/autocompleters/index.js
10753
10754
10755 ;// ./packages/editor/build-module/components/autosave-monitor/index.js
10756 /**
10757 * WordPress dependencies
10758 */
10759
10760
10761
10762
10763
10764 /**
10765 * Internal dependencies
10766 */
10767
10768 class AutosaveMonitor extends external_wp_element_namespaceObject.Component {
10769 constructor(props) {
10770 super(props);
10771 this.needsAutosave = !!(props.isDirty && props.isAutosaveable);
10772 }
10773 componentDidMount() {
10774 if (!this.props.disableIntervalChecks) {
10775 this.setAutosaveTimer();
10776 }
10777 }
10778 componentDidUpdate(prevProps) {
10779 if (this.props.disableIntervalChecks) {
10780 if (this.props.editsReference !== prevProps.editsReference) {
10781 this.props.autosave();
10782 }
10783 return;
10784 }
10785 if (this.props.interval !== prevProps.interval) {
10786 clearTimeout(this.timerId);
10787 this.setAutosaveTimer();
10788 }
10789 if (!this.props.isDirty) {
10790 this.needsAutosave = false;
10791 return;
10792 }
10793 if (this.props.isAutosaving && !prevProps.isAutosaving) {
10794 this.needsAutosave = false;
10795 return;
10796 }
10797 if (this.props.editsReference !== prevProps.editsReference) {
10798 this.needsAutosave = true;
10799 }
10800 }
10801 componentWillUnmount() {
10802 clearTimeout(this.timerId);
10803 }
10804 setAutosaveTimer(timeout = this.props.interval * 1000) {
10805 this.timerId = setTimeout(() => {
10806 this.autosaveTimerHandler();
10807 }, timeout);
10808 }
10809 autosaveTimerHandler() {
10810 if (!this.props.isAutosaveable) {
10811 this.setAutosaveTimer(1000);
10812 return;
10813 }
10814 if (this.needsAutosave) {
10815 this.needsAutosave = false;
10816 this.props.autosave();
10817 }
10818 this.setAutosaveTimer();
10819 }
10820 render() {
10821 return null;
10822 }
10823 }
10824
10825 /**
10826 * Monitors the changes made to the edited post and triggers autosave if necessary.
10827 *
10828 * The logic is straightforward: a check is performed every `props.interval` seconds. If any changes are detected, `props.autosave()` is called.
10829 * 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
10830 * the specific way of detecting changes.
10831 *
10832 * There are two caveats:
10833 * * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second.
10834 * * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`.
10835 *
10836 * @param {Object} props - The properties passed to the component.
10837 * @param {Function} props.autosave - The function to call when changes need to be saved.
10838 * @param {number} props.interval - The maximum time in seconds between an unsaved change and an autosave.
10839 * @param {boolean} props.isAutosaveable - If false, the check for changes is retried every second.
10840 * @param {boolean} props.disableIntervalChecks - If true, disables the timer and any change will immediately trigger `props.autosave()`.
10841 * @param {boolean} props.isDirty - Indicates if there are unsaved changes.
10842 *
10843 * @example
10844 * ```jsx
10845 * <AutosaveMonitor interval={30000} />
10846 * ```
10847 */
10848 /* harmony default export */ const autosave_monitor = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
10849 const {
10850 getReferenceByDistinctEdits
10851 } = select(external_wp_coreData_namespaceObject.store);
10852 const {
10853 isEditedPostDirty,
10854 isEditedPostAutosaveable,
10855 isAutosavingPost,
10856 getEditorSettings
10857 } = select(store_store);
10858 const {
10859 interval = getEditorSettings().autosaveInterval
10860 } = ownProps;
10861 return {
10862 editsReference: getReferenceByDistinctEdits(),
10863 isDirty: isEditedPostDirty(),
10864 isAutosaveable: isEditedPostAutosaveable(),
10865 isAutosaving: isAutosavingPost(),
10866 interval
10867 };
10868 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => ({
10869 autosave() {
10870 const {
10871 autosave = dispatch(store_store).autosave
10872 } = ownProps;
10873 autosave();
10874 }
10875 }))])(AutosaveMonitor));
10876
10877 ;// ./packages/icons/build-module/library/chevron-right-small.js
10878 /**
10879 * WordPress dependencies
10880 */
10881
10882
10883 const chevronRightSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
10884 xmlns: "http://www.w3.org/2000/svg",
10885 viewBox: "0 0 24 24",
10886 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
10887 d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
10888 })
10889 });
10890 /* harmony default export */ const chevron_right_small = (chevronRightSmall);
10891
10892 ;// ./packages/icons/build-module/library/chevron-left-small.js
10893 /**
10894 * WordPress dependencies
10895 */
10896
10897
10898 const chevronLeftSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
10899 xmlns: "http://www.w3.org/2000/svg",
10900 viewBox: "0 0 24 24",
10901 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
10902 d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z"
10903 })
10904 });
10905 /* harmony default export */ const chevron_left_small = (chevronLeftSmall);
10906
10907 ;// external ["wp","keycodes"]
10908 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
10909 ;// external ["wp","commands"]
10910 const external_wp_commands_namespaceObject = window["wp"]["commands"];
10911 ;// ./packages/editor/build-module/utils/pageTypeBadge.js
10912 /**
10913 * WordPress dependencies
10914 */
10915
10916
10917
10918
10919 /**
10920 * Internal dependencies
10921 */
10922
10923
10924 /**
10925 * Custom hook to get the page type badge for the current post on edit site view.
10926 */
10927 function usePageTypeBadge() {
10928 const {
10929 isFrontPage,
10930 isPostsPage
10931 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10932 const {
10933 getCurrentPostId
10934 } = select(store_store);
10935 const {
10936 canUser,
10937 getEditedEntityRecord
10938 } = select(external_wp_coreData_namespaceObject.store);
10939 const postId = getCurrentPostId();
10940 const siteSettings = canUser('read', {
10941 kind: 'root',
10942 name: 'site'
10943 }) ? getEditedEntityRecord('root', 'site') : undefined;
10944 return {
10945 isFrontPage: siteSettings?.page_on_front === postId,
10946 isPostsPage: siteSettings?.page_for_posts === postId
10947 };
10948 });
10949 if (isFrontPage) {
10950 return (0,external_wp_i18n_namespaceObject.__)('Homepage');
10951 } else if (isPostsPage) {
10952 return (0,external_wp_i18n_namespaceObject.__)('Posts Page');
10953 }
10954 return false;
10955 }
10956
10957 ;// ./packages/editor/build-module/components/document-bar/index.js
10958 /**
10959 * External dependencies
10960 */
10961
10962
10963 /**
10964 * WordPress dependencies
10965 */
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978 /**
10979 * Internal dependencies
10980 */
10981
10982
10983
10984
10985 /** @typedef {import("@wordpress/components").IconType} IconType */
10986
10987 const MotionButton = (0,external_wp_components_namespaceObject.__unstableMotion)(external_wp_components_namespaceObject.Button);
10988
10989 /**
10990 * This component renders a navigation bar at the top of the editor. It displays the title of the current document,
10991 * a back button (if applicable), and a command center button. It also handles different states of the document,
10992 * such as "not found" or "unsynced".
10993 *
10994 * @example
10995 * ```jsx
10996 * <DocumentBar />
10997 * ```
10998 * @param {Object} props The component props.
10999 * @param {string} props.title A title for the document, defaulting to the document or
11000 * template title currently being edited.
11001 * @param {IconType} props.icon An icon for the document, no default.
11002 * (A default icon indicating the document post type is no longer used.)
11003 *
11004 * @return {JSX.Element} The rendered DocumentBar component.
11005 */
11006 function DocumentBar(props) {
11007 const {
11008 postType,
11009 postTypeLabel,
11010 documentTitle,
11011 isNotFound,
11012 templateTitle,
11013 onNavigateToPreviousEntityRecord
11014 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11015 const {
11016 getCurrentPostType,
11017 getCurrentPostId,
11018 getEditorSettings,
11019 __experimentalGetTemplateInfo: getTemplateInfo
11020 } = select(store_store);
11021 const {
11022 getEditedEntityRecord,
11023 getPostType,
11024 isResolving: isResolvingSelector
11025 } = select(external_wp_coreData_namespaceObject.store);
11026 const _postType = getCurrentPostType();
11027 const _postId = getCurrentPostId();
11028 const _document = getEditedEntityRecord('postType', _postType, _postId);
11029 const _templateInfo = getTemplateInfo(_document);
11030 const _postTypeLabel = getPostType(_postType)?.labels?.singular_name;
11031 return {
11032 postType: _postType,
11033 postTypeLabel: _postTypeLabel,
11034 documentTitle: _document.title,
11035 isNotFound: !_document && !isResolvingSelector('getEditedEntityRecord', 'postType', _postType, _postId),
11036 templateTitle: _templateInfo.title,
11037 onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord
11038 };
11039 }, []);
11040 const {
11041 open: openCommandCenter
11042 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store);
11043 const isReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
11044 const isTemplate = TEMPLATE_POST_TYPES.includes(postType);
11045 const hasBackButton = !!onNavigateToPreviousEntityRecord;
11046 const entityTitle = isTemplate ? templateTitle : documentTitle;
11047 const title = props.title || entityTitle;
11048 const icon = props.icon;
11049 const pageTypeBadge = usePageTypeBadge();
11050 const mountedRef = (0,external_wp_element_namespaceObject.useRef)(false);
11051 (0,external_wp_element_namespaceObject.useEffect)(() => {
11052 mountedRef.current = true;
11053 }, []);
11054 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
11055 className: dist_clsx('editor-document-bar', {
11056 'has-back-button': hasBackButton
11057 }),
11058 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
11059 children: hasBackButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MotionButton, {
11060 className: "editor-document-bar__back",
11061 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right_small : chevron_left_small,
11062 onClick: event => {
11063 event.stopPropagation();
11064 onNavigateToPreviousEntityRecord();
11065 },
11066 size: "compact",
11067 initial: mountedRef.current ? {
11068 opacity: 0,
11069 transform: 'translateX(15%)'
11070 } : false // Don't show entry animation when DocumentBar mounts.
11071 ,
11072 animate: {
11073 opacity: 1,
11074 transform: 'translateX(0%)'
11075 },
11076 exit: {
11077 opacity: 0,
11078 transform: 'translateX(15%)'
11079 },
11080 transition: isReducedMotion ? {
11081 duration: 0
11082 } : undefined,
11083 children: (0,external_wp_i18n_namespaceObject.__)('Back')
11084 })
11085 }), isNotFound ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
11086 children: (0,external_wp_i18n_namespaceObject.__)('Document not found')
11087 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
11088 className: "editor-document-bar__command",
11089 onClick: () => openCommandCenter(),
11090 size: "compact",
11091 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
11092 className: "editor-document-bar__title"
11093 // Force entry animation when the back button is added or removed.
11094 ,
11095
11096 initial: mountedRef.current ? {
11097 opacity: 0,
11098 transform: hasBackButton ? 'translateX(15%)' : 'translateX(-15%)'
11099 } : false // Don't show entry animation when DocumentBar mounts.
11100 ,
11101 animate: {
11102 opacity: 1,
11103 transform: 'translateX(0%)'
11104 },
11105 transition: isReducedMotion ? {
11106 duration: 0
11107 } : undefined,
11108 children: [icon && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
11109 icon: icon
11110 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalText, {
11111 size: "body",
11112 as: "h1",
11113 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
11114 className: "editor-document-bar__post-title",
11115 children: title ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title) : (0,external_wp_i18n_namespaceObject.__)('No title')
11116 }), pageTypeBadge && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
11117 className: "editor-document-bar__post-type-label",
11118 children: `· ${pageTypeBadge}`
11119 }), postTypeLabel && !props.title && !pageTypeBadge && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
11120 className: "editor-document-bar__post-type-label",
11121 children: `· ${(0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postTypeLabel)}`
11122 })]
11123 })]
11124 }, hasBackButton), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
11125 className: "editor-document-bar__shortcut",
11126 children: external_wp_keycodes_namespaceObject.displayShortcut.primary('k')
11127 })]
11128 })]
11129 });
11130 }
11131
11132 ;// external ["wp","richText"]
11133 const external_wp_richText_namespaceObject = window["wp"]["richText"];
11134 ;// ./packages/editor/build-module/components/document-outline/item.js
11135 /**
11136 * External dependencies
11137 */
11138
11139
11140 const TableOfContentsItem = ({
11141 children,
11142 isValid,
11143 level,
11144 href,
11145 onSelect
11146 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
11147 className: dist_clsx('document-outline__item', `is-${level.toLowerCase()}`, {
11148 'is-invalid': !isValid
11149 }),
11150 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("a", {
11151 href: href,
11152 className: "document-outline__button",
11153 onClick: onSelect,
11154 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
11155 className: "document-outline__emdash",
11156 "aria-hidden": "true"
11157 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
11158 className: "document-outline__level",
11159 children: level
11160 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
11161 className: "document-outline__item-content",
11162 children: children
11163 })]
11164 })
11165 });
11166 /* harmony default export */ const document_outline_item = (TableOfContentsItem);
11167
11168 ;// ./packages/editor/build-module/components/document-outline/index.js
11169 /**
11170 * WordPress dependencies
11171 */
11172
11173
11174
11175
11176
11177
11178
11179 /**
11180 * Internal dependencies
11181 */
11182
11183
11184
11185 /**
11186 * Module constants
11187 */
11188
11189 const emptyHeadingContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
11190 children: (0,external_wp_i18n_namespaceObject.__)('(Empty heading)')
11191 });
11192 const incorrectLevelContent = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
11193 children: (0,external_wp_i18n_namespaceObject.__)('(Incorrect heading level)')
11194 }, "incorrect-message")];
11195 const singleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
11196 children: (0,external_wp_i18n_namespaceObject.__)('(Your theme may already use a H1 for the post title)')
11197 }, "incorrect-message-h1")];
11198 const multipleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-multiple-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
11199 children: (0,external_wp_i18n_namespaceObject.__)('(Multiple H1 headings are not recommended)')
11200 }, "incorrect-message-multiple-h1")];
11201 function EmptyOutlineIllustration() {
11202 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
11203 width: "138",
11204 height: "148",
11205 viewBox: "0 0 138 148",
11206 fill: "none",
11207 xmlns: "http://www.w3.org/2000/svg",
11208 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
11209 width: "138",
11210 height: "148",
11211 rx: "4",
11212 fill: "#F0F6FC"
11213 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
11214 x1: "44",
11215 y1: "28",
11216 x2: "24",
11217 y2: "28",
11218 stroke: "#DDDDDD"
11219 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
11220 x: "48",
11221 y: "16",
11222 width: "27",
11223 height: "23",
11224 rx: "4",
11225 fill: "#DDDDDD"
11226 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
11227 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",
11228 fill: "black"
11229 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
11230 x1: "55",
11231 y1: "59",
11232 x2: "24",
11233 y2: "59",
11234 stroke: "#DDDDDD"
11235 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
11236 x: "59",
11237 y: "47",
11238 width: "29",
11239 height: "23",
11240 rx: "4",
11241 fill: "#DDDDDD"
11242 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
11243 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",
11244 fill: "black"
11245 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
11246 x1: "80",
11247 y1: "90",
11248 x2: "24",
11249 y2: "90",
11250 stroke: "#DDDDDD"
11251 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
11252 x: "84",
11253 y: "78",
11254 width: "30",
11255 height: "23",
11256 rx: "4",
11257 fill: "#F0B849"
11258 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
11259 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",
11260 fill: "black"
11261 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
11262 x1: "66",
11263 y1: "121",
11264 x2: "24",
11265 y2: "121",
11266 stroke: "#DDDDDD"
11267 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
11268 x: "70",
11269 y: "109",
11270 width: "29",
11271 height: "23",
11272 rx: "4",
11273 fill: "#DDDDDD"
11274 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
11275 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",
11276 fill: "black"
11277 })]
11278 });
11279 }
11280
11281 /**
11282 * Returns an array of heading blocks enhanced with the following properties:
11283 * level - An integer with the heading level.
11284 * isEmpty - Flag indicating if the heading has no content.
11285 *
11286 * @param {?Array} blocks An array of blocks.
11287 *
11288 * @return {Array} An array of heading blocks enhanced with the properties described above.
11289 */
11290 const computeOutlineHeadings = (blocks = []) => {
11291 return blocks.flatMap((block = {}) => {
11292 if (block.name === 'core/heading') {
11293 return {
11294 ...block,
11295 level: block.attributes.level,
11296 isEmpty: isEmptyHeading(block)
11297 };
11298 }
11299 return computeOutlineHeadings(block.innerBlocks);
11300 });
11301 };
11302 const isEmptyHeading = heading => !heading.attributes.content || heading.attributes.content.trim().length === 0;
11303
11304 /**
11305 * Renders a document outline component.
11306 *
11307 * @param {Object} props Props.
11308 * @param {Function} props.onSelect Function to be called when an outline item is selected.
11309 * @param {boolean} props.isTitleSupported Indicates whether the title is supported.
11310 * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.
11311 *
11312 * @return {Component} The component to be rendered.
11313 */
11314 function DocumentOutline({
11315 onSelect,
11316 isTitleSupported,
11317 hasOutlineItemsDisabled
11318 }) {
11319 const {
11320 selectBlock
11321 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
11322 const {
11323 blocks,
11324 title
11325 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11326 var _postType$supports$ti;
11327 const {
11328 getBlocks
11329 } = select(external_wp_blockEditor_namespaceObject.store);
11330 const {
11331 getEditedPostAttribute
11332 } = select(store_store);
11333 const {
11334 getPostType
11335 } = select(external_wp_coreData_namespaceObject.store);
11336 const postType = getPostType(getEditedPostAttribute('type'));
11337 return {
11338 title: getEditedPostAttribute('title'),
11339 blocks: getBlocks(),
11340 isTitleSupported: (_postType$supports$ti = postType?.supports?.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false
11341 };
11342 });
11343 const headings = computeOutlineHeadings(blocks);
11344 if (headings.length < 1) {
11345 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
11346 className: "editor-document-outline has-no-headings",
11347 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EmptyOutlineIllustration, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
11348 children: (0,external_wp_i18n_namespaceObject.__)('Navigate the structure of your document and address issues like empty or incorrect heading levels.')
11349 })]
11350 });
11351 }
11352 let prevHeadingLevel = 1;
11353
11354 // Not great but it's the simplest way to locate the title right now.
11355 const titleNode = document.querySelector('.editor-post-title__input');
11356 const hasTitle = isTitleSupported && title && titleNode;
11357 const countByLevel = headings.reduce((acc, heading) => ({
11358 ...acc,
11359 [heading.level]: (acc[heading.level] || 0) + 1
11360 }), {});
11361 const hasMultipleH1 = countByLevel[1] > 1;
11362 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
11363 className: "document-outline",
11364 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
11365 children: [hasTitle && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_outline_item, {
11366 level: (0,external_wp_i18n_namespaceObject.__)('Title'),
11367 isValid: true,
11368 onSelect: onSelect,
11369 href: `#${titleNode.id}`,
11370 isDisabled: hasOutlineItemsDisabled,
11371 children: title
11372 }), headings.map((item, index) => {
11373 // Headings remain the same, go up by one, or down by any amount.
11374 // Otherwise there are missing levels.
11375 const isIncorrectLevel = item.level > prevHeadingLevel + 1;
11376 const isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle);
11377 prevHeadingLevel = item.level;
11378 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(document_outline_item, {
11379 level: `H${item.level}`,
11380 isValid: isValid,
11381 isDisabled: hasOutlineItemsDisabled,
11382 href: `#block-${item.clientId}`,
11383 onSelect: () => {
11384 selectBlock(item.clientId);
11385 onSelect?.();
11386 },
11387 children: [item.isEmpty ? emptyHeadingContent : (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.create)({
11388 html: item.attributes.content
11389 })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings]
11390 }, index);
11391 })]
11392 })
11393 });
11394 }
11395
11396 ;// ./packages/editor/build-module/components/document-outline/check.js
11397 /**
11398 * WordPress dependencies
11399 */
11400
11401
11402
11403 /**
11404 * Component check if there are any headings (core/heading blocks) present in the document.
11405 *
11406 * @param {Object} props Props.
11407 * @param {Element} props.children Children to be rendered.
11408 *
11409 * @return {Component|null} The component to be rendered or null if there are headings.
11410 */
11411 function DocumentOutlineCheck({
11412 children
11413 }) {
11414 const hasHeadings = (0,external_wp_data_namespaceObject.useSelect)(select => {
11415 const {
11416 getGlobalBlockCount
11417 } = select(external_wp_blockEditor_namespaceObject.store);
11418 return getGlobalBlockCount('core/heading') > 0;
11419 });
11420 if (hasHeadings) {
11421 return null;
11422 }
11423 return children;
11424 }
11425
11426 ;// ./packages/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.js
11427 /**
11428 * WordPress dependencies
11429 */
11430
11431
11432
11433
11434
11435
11436
11437 /**
11438 * Component for registering editor keyboard shortcuts.
11439 *
11440 * @return {Element} The component to be rendered.
11441 */
11442
11443 function EditorKeyboardShortcutsRegister() {
11444 // Registering the shortcuts.
11445 const {
11446 registerShortcut
11447 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
11448 (0,external_wp_element_namespaceObject.useEffect)(() => {
11449 registerShortcut({
11450 name: 'core/editor/toggle-mode',
11451 category: 'global',
11452 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'),
11453 keyCombination: {
11454 modifier: 'secondary',
11455 character: 'm'
11456 }
11457 });
11458 registerShortcut({
11459 name: 'core/editor/save',
11460 category: 'global',
11461 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
11462 keyCombination: {
11463 modifier: 'primary',
11464 character: 's'
11465 }
11466 });
11467 registerShortcut({
11468 name: 'core/editor/undo',
11469 category: 'global',
11470 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
11471 keyCombination: {
11472 modifier: 'primary',
11473 character: 'z'
11474 }
11475 });
11476 registerShortcut({
11477 name: 'core/editor/redo',
11478 category: 'global',
11479 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
11480 keyCombination: {
11481 modifier: 'primaryShift',
11482 character: 'z'
11483 },
11484 // Disable on Apple OS because it conflicts with the browser's
11485 // history shortcut. It's a fine alias for both Windows and Linux.
11486 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
11487 // Linux, we keep it as the default for consistency.
11488 aliases: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? [] : [{
11489 modifier: 'primary',
11490 character: 'y'
11491 }]
11492 });
11493 registerShortcut({
11494 name: 'core/editor/toggle-list-view',
11495 category: 'global',
11496 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the List View.'),
11497 keyCombination: {
11498 modifier: 'access',
11499 character: 'o'
11500 }
11501 });
11502 registerShortcut({
11503 name: 'core/editor/toggle-distraction-free',
11504 category: 'global',
11505 description: (0,external_wp_i18n_namespaceObject.__)('Enter or exit distraction free mode.'),
11506 keyCombination: {
11507 modifier: 'primaryShift',
11508 character: '\\'
11509 }
11510 });
11511 registerShortcut({
11512 name: 'core/editor/toggle-sidebar',
11513 category: 'global',
11514 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings panel.'),
11515 keyCombination: {
11516 modifier: 'primaryShift',
11517 character: ','
11518 }
11519 });
11520 registerShortcut({
11521 name: 'core/editor/keyboard-shortcuts',
11522 category: 'main',
11523 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
11524 keyCombination: {
11525 modifier: 'access',
11526 character: 'h'
11527 }
11528 });
11529 registerShortcut({
11530 name: 'core/editor/next-region',
11531 category: 'global',
11532 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
11533 keyCombination: {
11534 modifier: 'ctrl',
11535 character: '`'
11536 },
11537 aliases: [{
11538 modifier: 'access',
11539 character: 'n'
11540 }]
11541 });
11542 registerShortcut({
11543 name: 'core/editor/previous-region',
11544 category: 'global',
11545 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
11546 keyCombination: {
11547 modifier: 'ctrlShift',
11548 character: '`'
11549 },
11550 aliases: [{
11551 modifier: 'access',
11552 character: 'p'
11553 }, {
11554 modifier: 'ctrlShift',
11555 character: '~'
11556 }]
11557 });
11558 }, [registerShortcut]);
11559 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, {});
11560 }
11561 /* harmony default export */ const register_shortcuts = (EditorKeyboardShortcutsRegister);
11562
11563 ;// ./packages/icons/build-module/library/redo.js
11564 /**
11565 * WordPress dependencies
11566 */
11567
11568
11569 const redo_redo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
11570 xmlns: "http://www.w3.org/2000/svg",
11571 viewBox: "0 0 24 24",
11572 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
11573 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"
11574 })
11575 });
11576 /* harmony default export */ const library_redo = (redo_redo);
11577
11578 ;// ./packages/icons/build-module/library/undo.js
11579 /**
11580 * WordPress dependencies
11581 */
11582
11583
11584 const undo_undo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
11585 xmlns: "http://www.w3.org/2000/svg",
11586 viewBox: "0 0 24 24",
11587 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
11588 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"
11589 })
11590 });
11591 /* harmony default export */ const library_undo = (undo_undo);
11592
11593 ;// ./packages/editor/build-module/components/editor-history/redo.js
11594 /**
11595 * WordPress dependencies
11596 */
11597
11598
11599
11600
11601
11602
11603
11604 /**
11605 * Internal dependencies
11606 */
11607
11608
11609 function EditorHistoryRedo(props, ref) {
11610 const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y');
11611 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorRedo(), []);
11612 const {
11613 redo
11614 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11615 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
11616 __next40pxDefaultSize: true,
11617 ...props,
11618 ref: ref,
11619 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo
11620 /* translators: button label text should, if possible, be under 16 characters. */,
11621 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
11622 shortcut: shortcut
11623 // If there are no redo levels we don't want to actually disable this
11624 // button, because it will remove focus for keyboard users.
11625 // See: https://github.com/WordPress/gutenberg/issues/3486
11626 ,
11627 "aria-disabled": !hasRedo,
11628 onClick: hasRedo ? redo : undefined,
11629 className: "editor-history__redo"
11630 });
11631 }
11632
11633 /** @typedef {import('react').Ref<HTMLElement>} Ref */
11634
11635 /**
11636 * Renders the redo button for the editor history.
11637 *
11638 * @param {Object} props - Props.
11639 * @param {Ref} ref - Forwarded ref.
11640 *
11641 * @return {Component} The component to be rendered.
11642 */
11643 /* harmony default export */ const editor_history_redo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryRedo));
11644
11645 ;// ./packages/editor/build-module/components/editor-history/undo.js
11646 /**
11647 * WordPress dependencies
11648 */
11649
11650
11651
11652
11653
11654
11655
11656 /**
11657 * Internal dependencies
11658 */
11659
11660
11661 function EditorHistoryUndo(props, ref) {
11662 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorUndo(), []);
11663 const {
11664 undo
11665 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11666 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
11667 __next40pxDefaultSize: true,
11668 ...props,
11669 ref: ref,
11670 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo
11671 /* translators: button label text should, if possible, be under 16 characters. */,
11672 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
11673 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z')
11674 // If there are no undo levels we don't want to actually disable this
11675 // button, because it will remove focus for keyboard users.
11676 // See: https://github.com/WordPress/gutenberg/issues/3486
11677 ,
11678 "aria-disabled": !hasUndo,
11679 onClick: hasUndo ? undo : undefined,
11680 className: "editor-history__undo"
11681 });
11682 }
11683
11684 /** @typedef {import('react').Ref<HTMLElement>} Ref */
11685
11686 /**
11687 * Renders the undo button for the editor history.
11688 *
11689 * @param {Object} props - Props.
11690 * @param {Ref} ref - Forwarded ref.
11691 *
11692 * @return {Component} The component to be rendered.
11693 */
11694 /* harmony default export */ const editor_history_undo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryUndo));
11695
11696 ;// ./packages/editor/build-module/components/template-validation-notice/index.js
11697 /**
11698 * WordPress dependencies
11699 */
11700
11701
11702
11703
11704
11705
11706 function TemplateValidationNotice() {
11707 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
11708 const isValid = (0,external_wp_data_namespaceObject.useSelect)(select => {
11709 return select(external_wp_blockEditor_namespaceObject.store).isValidTemplate();
11710 }, []);
11711 const {
11712 setTemplateValidity,
11713 synchronizeTemplate
11714 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
11715 if (isValid) {
11716 return null;
11717 }
11718 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11719 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
11720 className: "editor-template-validation-notice",
11721 isDismissible: false,
11722 status: "warning",
11723 actions: [{
11724 label: (0,external_wp_i18n_namespaceObject.__)('Keep it as is'),
11725 onClick: () => setTemplateValidity(true)
11726 }, {
11727 label: (0,external_wp_i18n_namespaceObject.__)('Reset the template'),
11728 onClick: () => setShowConfirmDialog(true)
11729 }],
11730 children: (0,external_wp_i18n_namespaceObject.__)('The content of your post doesn’t match the template assigned to your post type.')
11731 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
11732 isOpen: showConfirmDialog,
11733 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Reset'),
11734 onConfirm: () => {
11735 setShowConfirmDialog(false);
11736 synchronizeTemplate();
11737 },
11738 onCancel: () => setShowConfirmDialog(false),
11739 size: "medium",
11740 children: (0,external_wp_i18n_namespaceObject.__)('Resetting the template may result in loss of content, do you want to continue?')
11741 })]
11742 });
11743 }
11744
11745 ;// ./packages/editor/build-module/components/editor-notices/index.js
11746 /**
11747 * WordPress dependencies
11748 */
11749
11750
11751
11752
11753 /**
11754 * Internal dependencies
11755 */
11756
11757
11758 /**
11759 * This component renders the notices displayed in the editor. It displays pinned notices first, followed by dismissible
11760 *
11761 * @example
11762 * ```jsx
11763 * <EditorNotices />
11764 * ```
11765 *
11766 * @return {JSX.Element} The rendered EditorNotices component.
11767 */
11768
11769 function EditorNotices() {
11770 const {
11771 notices
11772 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
11773 notices: select(external_wp_notices_namespaceObject.store).getNotices()
11774 }), []);
11775 const {
11776 removeNotice
11777 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
11778 const dismissibleNotices = notices.filter(({
11779 isDismissible,
11780 type
11781 }) => isDismissible && type === 'default');
11782 const nonDismissibleNotices = notices.filter(({
11783 isDismissible,
11784 type
11785 }) => !isDismissible && type === 'default');
11786 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11787 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
11788 notices: nonDismissibleNotices,
11789 className: "components-editor-notices__pinned"
11790 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
11791 notices: dismissibleNotices,
11792 className: "components-editor-notices__dismissible",
11793 onRemove: removeNotice,
11794 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateValidationNotice, {})
11795 })]
11796 });
11797 }
11798 /* harmony default export */ const editor_notices = (EditorNotices);
11799
11800 ;// ./packages/editor/build-module/components/editor-snackbars/index.js
11801 /**
11802 * WordPress dependencies
11803 */
11804
11805
11806
11807
11808 // Last three notices. Slices from the tail end of the list.
11809
11810 const MAX_VISIBLE_NOTICES = -3;
11811
11812 /**
11813 * Renders the editor snackbars component.
11814 *
11815 * @return {JSX.Element} The rendered component.
11816 */
11817 function EditorSnackbars() {
11818 const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []);
11819 const {
11820 removeNotice
11821 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
11822 const snackbarNotices = notices.filter(({
11823 type
11824 }) => type === 'snackbar').slice(MAX_VISIBLE_NOTICES);
11825 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SnackbarList, {
11826 notices: snackbarNotices,
11827 className: "components-editor-notices__snackbar",
11828 onRemove: removeNotice
11829 });
11830 }
11831
11832 ;// ./packages/editor/build-module/components/entities-saved-states/entity-record-item.js
11833 /**
11834 * WordPress dependencies
11835 */
11836
11837
11838
11839
11840
11841
11842 /**
11843 * Internal dependencies
11844 */
11845
11846
11847
11848 function EntityRecordItem({
11849 record,
11850 checked,
11851 onChange
11852 }) {
11853 const {
11854 name,
11855 kind,
11856 title,
11857 key
11858 } = record;
11859
11860 // Handle templates that might use default descriptive titles.
11861 const {
11862 entityRecordTitle,
11863 hasPostMetaChanges
11864 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11865 if ('postType' !== kind || 'wp_template' !== name) {
11866 return {
11867 entityRecordTitle: title,
11868 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
11869 };
11870 }
11871 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key);
11872 return {
11873 entityRecordTitle: select(store_store).__experimentalGetTemplateInfo(template).title,
11874 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
11875 };
11876 }, [name, kind, title, key]);
11877 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11878 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
11879 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
11880 __nextHasNoMarginBottom: true,
11881 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(entityRecordTitle) || (0,external_wp_i18n_namespaceObject.__)('Untitled'),
11882 checked: checked,
11883 onChange: onChange
11884 })
11885 }), hasPostMetaChanges && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
11886 className: "entities-saved-states__changes",
11887 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
11888 children: (0,external_wp_i18n_namespaceObject.__)('Post Meta.')
11889 })
11890 })]
11891 });
11892 }
11893
11894 ;// ./packages/editor/build-module/components/entities-saved-states/entity-type-list.js
11895 /**
11896 * WordPress dependencies
11897 */
11898
11899
11900
11901
11902
11903
11904
11905 /**
11906 * Internal dependencies
11907 */
11908
11909
11910
11911 const {
11912 getGlobalStylesChanges,
11913 GlobalStylesContext
11914 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
11915 function getEntityDescription(entity, count) {
11916 switch (entity) {
11917 case 'site':
11918 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.');
11919 case 'wp_template':
11920 return (0,external_wp_i18n_namespaceObject.__)('This change will affect pages and posts that use this template.');
11921 case 'page':
11922 case 'post':
11923 return (0,external_wp_i18n_namespaceObject.__)('The following has been modified.');
11924 }
11925 }
11926 function GlobalStylesDescription({
11927 record
11928 }) {
11929 const {
11930 user: currentEditorGlobalStyles
11931 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
11932 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]);
11933 const globalStylesChanges = getGlobalStylesChanges(currentEditorGlobalStyles, savedRecord, {
11934 maxResults: 10
11935 });
11936 return globalStylesChanges.length ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
11937 className: "entities-saved-states__changes",
11938 children: globalStylesChanges.map(change => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
11939 children: change
11940 }, change))
11941 }) : null;
11942 }
11943 function EntityDescription({
11944 record,
11945 count
11946 }) {
11947 if ('globalStyles' === record?.name) {
11948 return null;
11949 }
11950 const description = getEntityDescription(record?.name, count);
11951 return description ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
11952 children: description
11953 }) : null;
11954 }
11955 function EntityTypeList({
11956 list,
11957 unselectedEntities,
11958 setUnselectedEntities
11959 }) {
11960 const count = list.length;
11961 const firstRecord = list[0];
11962 const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
11963 let entityLabel = entityConfig.label;
11964 if (firstRecord?.name === 'wp_template_part') {
11965 entityLabel = 1 === count ? (0,external_wp_i18n_namespaceObject.__)('Template Part') : (0,external_wp_i18n_namespaceObject.__)('Template Parts');
11966 }
11967 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
11968 title: entityLabel,
11969 initialOpen: true,
11970 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityDescription, {
11971 record: firstRecord,
11972 count: count
11973 }), list.map(record => {
11974 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityRecordItem, {
11975 record: record,
11976 checked: !unselectedEntities.some(elt => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property),
11977 onChange: value => setUnselectedEntities(record, value)
11978 }, record.key || record.property);
11979 }), 'globalStyles' === firstRecord?.name && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(GlobalStylesDescription, {
11980 record: firstRecord
11981 })]
11982 });
11983 }
11984
11985 ;// ./packages/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.js
11986 /**
11987 * WordPress dependencies
11988 */
11989
11990
11991
11992
11993 /**
11994 * Custom hook that determines if any entities are dirty (edited) and provides a way to manage selected/unselected entities.
11995 *
11996 * @return {Object} An object containing the following properties:
11997 * - dirtyEntityRecords: An array of dirty entity records.
11998 * - isDirty: A boolean indicating if there are any dirty entity records.
11999 * - setUnselectedEntities: A function to set the unselected entities.
12000 * - unselectedEntities: An array of unselected entities.
12001 */
12002 const useIsDirty = () => {
12003 const {
12004 editedEntities,
12005 siteEdits,
12006 siteEntityConfig
12007 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12008 const {
12009 __experimentalGetDirtyEntityRecords,
12010 getEntityRecordEdits,
12011 getEntityConfig
12012 } = select(external_wp_coreData_namespaceObject.store);
12013 return {
12014 editedEntities: __experimentalGetDirtyEntityRecords(),
12015 siteEdits: getEntityRecordEdits('root', 'site'),
12016 siteEntityConfig: getEntityConfig('root', 'site')
12017 };
12018 }, []);
12019 const dirtyEntityRecords = (0,external_wp_element_namespaceObject.useMemo)(() => {
12020 var _siteEntityConfig$met;
12021 // Remove site object and decouple into its edited pieces.
12022 const editedEntitiesWithoutSite = editedEntities.filter(record => !(record.kind === 'root' && record.name === 'site'));
12023 const siteEntityLabels = (_siteEntityConfig$met = siteEntityConfig?.meta?.labels) !== null && _siteEntityConfig$met !== void 0 ? _siteEntityConfig$met : {};
12024 const editedSiteEntities = [];
12025 for (const property in siteEdits) {
12026 editedSiteEntities.push({
12027 kind: 'root',
12028 name: 'site',
12029 title: siteEntityLabels[property] || property,
12030 property
12031 });
12032 }
12033 return [...editedEntitiesWithoutSite, ...editedSiteEntities];
12034 }, [editedEntities, siteEdits, siteEntityConfig]);
12035
12036 // Unchecked entities to be ignored by save function.
12037 const [unselectedEntities, _setUnselectedEntities] = (0,external_wp_element_namespaceObject.useState)([]);
12038 const setUnselectedEntities = ({
12039 kind,
12040 name,
12041 key,
12042 property
12043 }, checked) => {
12044 if (checked) {
12045 _setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property));
12046 } else {
12047 _setUnselectedEntities([...unselectedEntities, {
12048 kind,
12049 name,
12050 key,
12051 property
12052 }]);
12053 }
12054 };
12055 const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
12056 return {
12057 dirtyEntityRecords,
12058 isDirty,
12059 setUnselectedEntities,
12060 unselectedEntities
12061 };
12062 };
12063
12064 ;// ./packages/editor/build-module/components/entities-saved-states/index.js
12065 /**
12066 * WordPress dependencies
12067 */
12068
12069
12070
12071
12072
12073
12074 /**
12075 * Internal dependencies
12076 */
12077
12078
12079
12080
12081
12082 function identity(values) {
12083 return values;
12084 }
12085
12086 /**
12087 * Renders the component for managing saved states of entities.
12088 *
12089 * @param {Object} props The component props.
12090 * @param {Function} props.close The function to close the dialog.
12091 * @param {Function} props.renderDialog The function to render the dialog.
12092 *
12093 * @return {JSX.Element} The rendered component.
12094 */
12095 function EntitiesSavedStates({
12096 close,
12097 renderDialog = undefined
12098 }) {
12099 const isDirtyProps = useIsDirty();
12100 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStatesExtensible, {
12101 close: close,
12102 renderDialog: renderDialog,
12103 ...isDirtyProps
12104 });
12105 }
12106
12107 /**
12108 * Renders a panel for saving entities with dirty records.
12109 *
12110 * @param {Object} props The component props.
12111 * @param {string} props.additionalPrompt Additional prompt to display.
12112 * @param {Function} props.close Function to close the panel.
12113 * @param {Function} props.onSave Function to call when saving entities.
12114 * @param {boolean} props.saveEnabled Flag indicating if save is enabled.
12115 * @param {string} props.saveLabel Label for the save button.
12116 * @param {Function} props.renderDialog Function to render a custom dialog.
12117 * @param {Array} props.dirtyEntityRecords Array of dirty entity records.
12118 * @param {boolean} props.isDirty Flag indicating if there are dirty entities.
12119 * @param {Function} props.setUnselectedEntities Function to set unselected entities.
12120 * @param {Array} props.unselectedEntities Array of unselected entities.
12121 *
12122 * @return {JSX.Element} The rendered component.
12123 */
12124 function EntitiesSavedStatesExtensible({
12125 additionalPrompt = undefined,
12126 close,
12127 onSave = identity,
12128 saveEnabled: saveEnabledProp = undefined,
12129 saveLabel = (0,external_wp_i18n_namespaceObject.__)('Save'),
12130 renderDialog = undefined,
12131 dirtyEntityRecords,
12132 isDirty,
12133 setUnselectedEntities,
12134 unselectedEntities
12135 }) {
12136 const saveButtonRef = (0,external_wp_element_namespaceObject.useRef)();
12137 const {
12138 saveDirtyEntities
12139 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
12140 // To group entities by type.
12141 const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
12142 const {
12143 name
12144 } = record;
12145 if (!acc[name]) {
12146 acc[name] = [];
12147 }
12148 acc[name].push(record);
12149 return acc;
12150 }, {});
12151
12152 // Sort entity groups.
12153 const {
12154 site: siteSavables,
12155 wp_template: templateSavables,
12156 wp_template_part: templatePartSavables,
12157 ...contentSavables
12158 } = partitionedSavables;
12159 const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray);
12160 const saveEnabled = saveEnabledProp !== null && saveEnabledProp !== void 0 ? saveEnabledProp : isDirty;
12161 // Explicitly define this with no argument passed. Using `close` on
12162 // its own will use the event object in place of the expected saved entities.
12163 const dismissPanel = (0,external_wp_element_namespaceObject.useCallback)(() => close(), [close]);
12164 const [saveDialogRef, saveDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
12165 onClose: () => dismissPanel()
12166 });
12167 const dialogLabel = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'label');
12168 const dialogDescription = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'description');
12169 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12170 ref: saveDialogRef,
12171 ...saveDialogProps,
12172 className: "entities-saved-states__panel",
12173 role: renderDialog ? 'dialog' : undefined,
12174 "aria-labelledby": renderDialog ? dialogLabel : undefined,
12175 "aria-describedby": renderDialog ? dialogDescription : undefined,
12176 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
12177 className: "entities-saved-states__panel-header",
12178 gap: 2,
12179 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
12180 isBlock: true,
12181 as: external_wp_components_namespaceObject.Button,
12182 variant: "secondary",
12183 size: "compact",
12184 onClick: dismissPanel,
12185 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
12186 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
12187 isBlock: true,
12188 as: external_wp_components_namespaceObject.Button,
12189 ref: saveButtonRef,
12190 variant: "primary",
12191 size: "compact",
12192 disabled: !saveEnabled,
12193 accessibleWhenDisabled: true,
12194 onClick: () => saveDirtyEntities({
12195 onSave,
12196 dirtyEntityRecords,
12197 entitiesToSkip: unselectedEntities,
12198 close
12199 }),
12200 className: "editor-entities-saved-states__save-button",
12201 children: saveLabel
12202 })]
12203 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12204 className: "entities-saved-states__text-prompt",
12205 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12206 className: "entities-saved-states__text-prompt--header-wrapper",
12207 id: renderDialog ? dialogLabel : undefined,
12208 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
12209 className: "entities-saved-states__text-prompt--header",
12210 children: (0,external_wp_i18n_namespaceObject.__)('Are you ready to save?')
12211 }), additionalPrompt]
12212 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
12213 id: renderDialog ? dialogDescription : undefined,
12214 children: isDirty ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %d: number of site changes waiting to be saved. */
12215 (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), {
12216 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {})
12217 }) : (0,external_wp_i18n_namespaceObject.__)('Select the items you want to save.')
12218 })]
12219 }), sortedPartitionedSavables.map(list => {
12220 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityTypeList, {
12221 list: list,
12222 unselectedEntities: unselectedEntities,
12223 setUnselectedEntities: setUnselectedEntities
12224 }, list[0].name);
12225 })]
12226 });
12227 }
12228
12229 ;// ./packages/editor/build-module/components/error-boundary/index.js
12230 /**
12231 * WordPress dependencies
12232 */
12233
12234
12235
12236
12237
12238
12239
12240
12241 /**
12242 * Internal dependencies
12243 */
12244
12245
12246 function getContent() {
12247 try {
12248 // While `select` in a component is generally discouraged, it is
12249 // used here because it (a) reduces the chance of data loss in the
12250 // case of additional errors by performing a direct retrieval and
12251 // (b) avoids the performance cost associated with unnecessary
12252 // content serialization throughout the lifetime of a non-erroring
12253 // application.
12254 return (0,external_wp_data_namespaceObject.select)(store_store).getEditedPostContent();
12255 } catch (error) {}
12256 }
12257 function CopyButton({
12258 text,
12259 children
12260 }) {
12261 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
12262 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12263 __next40pxDefaultSize: true,
12264 variant: "secondary",
12265 ref: ref,
12266 children: children
12267 });
12268 }
12269 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
12270 constructor() {
12271 super(...arguments);
12272 this.state = {
12273 error: null
12274 };
12275 }
12276 componentDidCatch(error) {
12277 (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error);
12278 }
12279 static getDerivedStateFromError(error) {
12280 return {
12281 error
12282 };
12283 }
12284 render() {
12285 const {
12286 error
12287 } = this.state;
12288 if (!error) {
12289 return this.props.children;
12290 }
12291 const actions = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
12292 text: getContent,
12293 children: (0,external_wp_i18n_namespaceObject.__)('Copy Post Text')
12294 }, "copy-post"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
12295 text: error.stack,
12296 children: (0,external_wp_i18n_namespaceObject.__)('Copy Error')
12297 }, "copy-error")];
12298 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.Warning, {
12299 className: "editor-error-boundary",
12300 actions: actions,
12301 children: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.')
12302 });
12303 }
12304 }
12305
12306 /**
12307 * ErrorBoundary is used to catch JavaScript errors anywhere in a child component tree, log those errors, and display a fallback UI.
12308 *
12309 * It uses the lifecycle methods getDerivedStateFromError and componentDidCatch to catch errors in a child component tree.
12310 *
12311 * getDerivedStateFromError is used to render a fallback UI after an error has been thrown, and componentDidCatch is used to log error information.
12312 *
12313 * @class ErrorBoundary
12314 * @augments Component
12315 */
12316 /* harmony default export */ const error_boundary = (ErrorBoundary);
12317
12318 ;// ./packages/editor/build-module/components/local-autosave-monitor/index.js
12319 /**
12320 * WordPress dependencies
12321 */
12322
12323
12324
12325
12326
12327
12328
12329 /**
12330 * Internal dependencies
12331 */
12332
12333
12334
12335
12336 const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
12337 let hasStorageSupport;
12338
12339 /**
12340 * Function which returns true if the current environment supports browser
12341 * sessionStorage, or false otherwise. The result of this function is cached and
12342 * reused in subsequent invocations.
12343 */
12344 const hasSessionStorageSupport = () => {
12345 if (hasStorageSupport !== undefined) {
12346 return hasStorageSupport;
12347 }
12348 try {
12349 // Private Browsing in Safari 10 and earlier will throw an error when
12350 // attempting to set into sessionStorage. The test here is intentional in
12351 // causing a thrown error as condition bailing from local autosave.
12352 window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
12353 window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
12354 hasStorageSupport = true;
12355 } catch {
12356 hasStorageSupport = false;
12357 }
12358 return hasStorageSupport;
12359 };
12360
12361 /**
12362 * Custom hook which manages the creation of a notice prompting the user to
12363 * restore a local autosave, if one exists.
12364 */
12365 function useAutosaveNotice() {
12366 const {
12367 postId,
12368 isEditedPostNew,
12369 hasRemoteAutosave
12370 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
12371 postId: select(store_store).getCurrentPostId(),
12372 isEditedPostNew: select(store_store).isEditedPostNew(),
12373 hasRemoteAutosave: !!select(store_store).getEditorSettings().autosave
12374 }), []);
12375 const {
12376 getEditedPostAttribute
12377 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
12378 const {
12379 createWarningNotice,
12380 removeNotice
12381 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
12382 const {
12383 editPost,
12384 resetEditorBlocks
12385 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12386 (0,external_wp_element_namespaceObject.useEffect)(() => {
12387 let localAutosave = localAutosaveGet(postId, isEditedPostNew);
12388 if (!localAutosave) {
12389 return;
12390 }
12391 try {
12392 localAutosave = JSON.parse(localAutosave);
12393 } catch {
12394 // Not usable if it can't be parsed.
12395 return;
12396 }
12397 const {
12398 post_title: title,
12399 content,
12400 excerpt
12401 } = localAutosave;
12402 const edits = {
12403 title,
12404 content,
12405 excerpt
12406 };
12407 {
12408 // Only display a notice if there is a difference between what has been
12409 // saved and that which is stored in sessionStorage.
12410 const hasDifference = Object.keys(edits).some(key => {
12411 return edits[key] !== getEditedPostAttribute(key);
12412 });
12413 if (!hasDifference) {
12414 // If there is no difference, it can be safely ejected from storage.
12415 localAutosaveClear(postId, isEditedPostNew);
12416 return;
12417 }
12418 }
12419 if (hasRemoteAutosave) {
12420 return;
12421 }
12422 const id = 'wpEditorAutosaveRestore';
12423 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('The backup of this post in your browser is different from the version below.'), {
12424 id,
12425 actions: [{
12426 label: (0,external_wp_i18n_namespaceObject.__)('Restore the backup'),
12427 onClick() {
12428 const {
12429 content: editsContent,
12430 ...editsWithoutContent
12431 } = edits;
12432 editPost(editsWithoutContent);
12433 resetEditorBlocks((0,external_wp_blocks_namespaceObject.parse)(edits.content));
12434 removeNotice(id);
12435 }
12436 }]
12437 });
12438 }, [isEditedPostNew, postId]);
12439 }
12440
12441 /**
12442 * Custom hook which ejects a local autosave after a successful save occurs.
12443 */
12444 function useAutosavePurge() {
12445 const {
12446 postId,
12447 isEditedPostNew,
12448 isDirty,
12449 isAutosaving,
12450 didError
12451 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
12452 postId: select(store_store).getCurrentPostId(),
12453 isEditedPostNew: select(store_store).isEditedPostNew(),
12454 isDirty: select(store_store).isEditedPostDirty(),
12455 isAutosaving: select(store_store).isAutosavingPost(),
12456 didError: select(store_store).didPostSaveRequestFail()
12457 }), []);
12458 const lastIsDirtyRef = (0,external_wp_element_namespaceObject.useRef)(isDirty);
12459 const lastIsAutosavingRef = (0,external_wp_element_namespaceObject.useRef)(isAutosaving);
12460 (0,external_wp_element_namespaceObject.useEffect)(() => {
12461 if (!didError && (lastIsAutosavingRef.current && !isAutosaving || lastIsDirtyRef.current && !isDirty)) {
12462 localAutosaveClear(postId, isEditedPostNew);
12463 }
12464 lastIsDirtyRef.current = isDirty;
12465 lastIsAutosavingRef.current = isAutosaving;
12466 }, [isDirty, isAutosaving, didError]);
12467
12468 // Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.
12469 const wasEditedPostNew = (0,external_wp_compose_namespaceObject.usePrevious)(isEditedPostNew);
12470 const prevPostId = (0,external_wp_compose_namespaceObject.usePrevious)(postId);
12471 (0,external_wp_element_namespaceObject.useEffect)(() => {
12472 if (prevPostId === postId && wasEditedPostNew && !isEditedPostNew) {
12473 localAutosaveClear(postId, true);
12474 }
12475 }, [isEditedPostNew, postId]);
12476 }
12477 function LocalAutosaveMonitor() {
12478 const {
12479 autosave
12480 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12481 const deferredAutosave = (0,external_wp_element_namespaceObject.useCallback)(() => {
12482 requestIdleCallback(() => autosave({
12483 local: true
12484 }));
12485 }, []);
12486 useAutosaveNotice();
12487 useAutosavePurge();
12488 const localAutosaveInterval = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().localAutosaveInterval, []);
12489 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(autosave_monitor, {
12490 interval: localAutosaveInterval,
12491 autosave: deferredAutosave
12492 });
12493 }
12494
12495 /**
12496 * Monitors local autosaves of a post in the editor.
12497 * It uses several hooks and functions to manage autosave behavior:
12498 * - `useAutosaveNotice` hook: Manages the creation of a notice prompting the user to restore a local autosave, if one exists.
12499 * - `useAutosavePurge` hook: Ejects a local autosave after a successful save occurs.
12500 * - `hasSessionStorageSupport` function: Checks if the current environment supports browser sessionStorage.
12501 * - `LocalAutosaveMonitor` component: Uses the `AutosaveMonitor` component to perform autosaves at a specified interval.
12502 *
12503 * The module also checks for sessionStorage support and conditionally exports the `LocalAutosaveMonitor` component based on that.
12504 *
12505 * @module LocalAutosaveMonitor
12506 */
12507 /* harmony default export */ const local_autosave_monitor = ((0,external_wp_compose_namespaceObject.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor));
12508
12509 ;// ./packages/editor/build-module/components/page-attributes/check.js
12510 /**
12511 * WordPress dependencies
12512 */
12513
12514
12515
12516 /**
12517 * Internal dependencies
12518 */
12519
12520
12521 /**
12522 * Wrapper component that renders its children only if the post type supports page attributes.
12523 *
12524 * @param {Object} props - The component props.
12525 * @param {Element} props.children - The child components to render.
12526 *
12527 * @return {Component|null} The rendered child components or null if page attributes are not supported.
12528 */
12529 function PageAttributesCheck({
12530 children
12531 }) {
12532 const supportsPageAttributes = (0,external_wp_data_namespaceObject.useSelect)(select => {
12533 const {
12534 getEditedPostAttribute
12535 } = select(store_store);
12536 const {
12537 getPostType
12538 } = select(external_wp_coreData_namespaceObject.store);
12539 const postType = getPostType(getEditedPostAttribute('type'));
12540 return !!postType?.supports?.['page-attributes'];
12541 }, []);
12542
12543 // Only render fields if post type supports page attributes or available templates exist.
12544 if (!supportsPageAttributes) {
12545 return null;
12546 }
12547 return children;
12548 }
12549 /* harmony default export */ const page_attributes_check = (PageAttributesCheck);
12550
12551 ;// ./packages/editor/build-module/components/post-type-support-check/index.js
12552 /**
12553 * WordPress dependencies
12554 */
12555
12556
12557
12558 /**
12559 * Internal dependencies
12560 */
12561
12562
12563 /**
12564 * A component which renders its own children only if the current editor post
12565 * type supports one of the given `supportKeys` prop.
12566 *
12567 * @param {Object} props Props.
12568 * @param {Element} props.children Children to be rendered if post
12569 * type supports.
12570 * @param {(string|string[])} props.supportKeys String or string array of keys
12571 * to test.
12572 *
12573 * @return {Component} The component to be rendered.
12574 */
12575 function PostTypeSupportCheck({
12576 children,
12577 supportKeys
12578 }) {
12579 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
12580 const {
12581 getEditedPostAttribute
12582 } = select(store_store);
12583 const {
12584 getPostType
12585 } = select(external_wp_coreData_namespaceObject.store);
12586 return getPostType(getEditedPostAttribute('type'));
12587 }, []);
12588 let isSupported = !!postType;
12589 if (postType) {
12590 isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => !!postType.supports[key]);
12591 }
12592 if (!isSupported) {
12593 return null;
12594 }
12595 return children;
12596 }
12597 /* harmony default export */ const post_type_support_check = (PostTypeSupportCheck);
12598
12599 ;// ./packages/editor/build-module/components/page-attributes/order.js
12600 /**
12601 * WordPress dependencies
12602 */
12603
12604
12605
12606
12607
12608 /**
12609 * Internal dependencies
12610 */
12611
12612
12613
12614 function PageAttributesOrder() {
12615 const order = (0,external_wp_data_namespaceObject.useSelect)(select => {
12616 var _select$getEditedPost;
12617 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('menu_order')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 0;
12618 }, []);
12619 const {
12620 editPost
12621 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12622 const [orderInput, setOrderInput] = (0,external_wp_element_namespaceObject.useState)(null);
12623 const setUpdatedOrder = value => {
12624 setOrderInput(value);
12625 const newOrder = Number(value);
12626 if (Number.isInteger(newOrder) && value.trim?.() !== '') {
12627 editPost({
12628 menu_order: newOrder
12629 });
12630 }
12631 };
12632 const value = orderInput !== null && orderInput !== void 0 ? orderInput : order;
12633 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
12634 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexBlock, {
12635 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
12636 __next40pxDefaultSize: true,
12637 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
12638 help: (0,external_wp_i18n_namespaceObject.__)('Set the page order.'),
12639 value: value,
12640 onChange: setUpdatedOrder,
12641 hideLabelFromVision: true,
12642 onBlur: () => {
12643 setOrderInput(null);
12644 }
12645 })
12646 })
12647 });
12648 }
12649
12650 /**
12651 * Renders the Page Attributes Order component. A number input in an editor interface
12652 * for setting the order of a given page.
12653 * The component is now not used in core but was kept for backward compatibility.
12654 *
12655 * @return {Component} The component to be rendered.
12656 */
12657 function PageAttributesOrderWithChecks() {
12658 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12659 supportKeys: "page-attributes",
12660 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesOrder, {})
12661 });
12662 }
12663
12664 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js
12665 var remove_accents = __webpack_require__(9681);
12666 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents);
12667 ;// ./packages/editor/build-module/components/post-panel-row/index.js
12668 /**
12669 * External dependencies
12670 */
12671
12672
12673 /**
12674 * WordPress dependencies
12675 */
12676
12677
12678
12679 const PostPanelRow = (0,external_wp_element_namespaceObject.forwardRef)(({
12680 className,
12681 label,
12682 children
12683 }, ref) => {
12684 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
12685 className: dist_clsx('editor-post-panel__row', className),
12686 ref: ref,
12687 children: [label && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
12688 className: "editor-post-panel__row-label",
12689 children: label
12690 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
12691 className: "editor-post-panel__row-control",
12692 children: children
12693 })]
12694 });
12695 });
12696 /* harmony default export */ const post_panel_row = (PostPanelRow);
12697
12698 ;// ./packages/editor/build-module/utils/terms.js
12699 /**
12700 * WordPress dependencies
12701 */
12702
12703
12704 /**
12705 * Returns terms in a tree form.
12706 *
12707 * @param {Array} flatTerms Array of terms in flat format.
12708 *
12709 * @return {Array} Array of terms in tree format.
12710 */
12711 function buildTermsTree(flatTerms) {
12712 const flatTermsWithParentAndChildren = flatTerms.map(term => {
12713 return {
12714 children: [],
12715 parent: undefined,
12716 ...term
12717 };
12718 });
12719
12720 // All terms should have a `parent` because we're about to index them by it.
12721 if (flatTermsWithParentAndChildren.some(({
12722 parent
12723 }) => parent === undefined)) {
12724 return flatTermsWithParentAndChildren;
12725 }
12726 const termsByParent = flatTermsWithParentAndChildren.reduce((acc, term) => {
12727 const {
12728 parent
12729 } = term;
12730 if (!acc[parent]) {
12731 acc[parent] = [];
12732 }
12733 acc[parent].push(term);
12734 return acc;
12735 }, {});
12736 const fillWithChildren = terms => {
12737 return terms.map(term => {
12738 const children = termsByParent[term.id];
12739 return {
12740 ...term,
12741 children: children && children.length ? fillWithChildren(children) : []
12742 };
12743 });
12744 };
12745 return fillWithChildren(termsByParent['0'] || []);
12746 }
12747 const unescapeString = arg => {
12748 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(arg);
12749 };
12750
12751 /**
12752 * Returns a term object with name unescaped.
12753 *
12754 * @param {Object} term The term object to unescape.
12755 *
12756 * @return {Object} Term object with name property unescaped.
12757 */
12758 const unescapeTerm = term => {
12759 return {
12760 ...term,
12761 name: unescapeString(term.name)
12762 };
12763 };
12764
12765 /**
12766 * Returns an array of term objects with names unescaped.
12767 * The unescape of each term is performed using the unescapeTerm function.
12768 *
12769 * @param {Object[]} terms Array of term objects to unescape.
12770 *
12771 * @return {Object[]} Array of term objects unescaped.
12772 */
12773 const unescapeTerms = terms => {
12774 return (terms !== null && terms !== void 0 ? terms : []).map(unescapeTerm);
12775 };
12776
12777 ;// ./packages/editor/build-module/components/page-attributes/parent.js
12778 /**
12779 * External dependencies
12780 */
12781
12782
12783 /**
12784 * WordPress dependencies
12785 */
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796 /**
12797 * Internal dependencies
12798 */
12799
12800
12801
12802
12803 function getTitle(post) {
12804 return post?.title?.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title.rendered) : `#${post.id} (${(0,external_wp_i18n_namespaceObject.__)('no title')})`;
12805 }
12806 const getItemPriority = (name, searchValue) => {
12807 const normalizedName = remove_accents_default()(name || '').toLowerCase();
12808 const normalizedSearch = remove_accents_default()(searchValue || '').toLowerCase();
12809 if (normalizedName === normalizedSearch) {
12810 return 0;
12811 }
12812 if (normalizedName.startsWith(normalizedSearch)) {
12813 return normalizedName.length;
12814 }
12815 return Infinity;
12816 };
12817
12818 /**
12819 * Renders the Page Attributes Parent component. A dropdown menu in an editor interface
12820 * for selecting the parent page of a given page.
12821 *
12822 * @return {Component|null} The component to be rendered. Return null if post type is not hierarchical.
12823 */
12824 function PageAttributesParent() {
12825 const {
12826 editPost
12827 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12828 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(false);
12829 const {
12830 isHierarchical,
12831 parentPostId,
12832 parentPostTitle,
12833 pageItems
12834 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12835 var _pType$hierarchical;
12836 const {
12837 getPostType,
12838 getEntityRecords,
12839 getEntityRecord
12840 } = select(external_wp_coreData_namespaceObject.store);
12841 const {
12842 getCurrentPostId,
12843 getEditedPostAttribute
12844 } = select(store_store);
12845 const postTypeSlug = getEditedPostAttribute('type');
12846 const pageId = getEditedPostAttribute('parent');
12847 const pType = getPostType(postTypeSlug);
12848 const postId = getCurrentPostId();
12849 const postIsHierarchical = (_pType$hierarchical = pType?.hierarchical) !== null && _pType$hierarchical !== void 0 ? _pType$hierarchical : false;
12850 const query = {
12851 per_page: 100,
12852 exclude: postId,
12853 parent_exclude: postId,
12854 orderby: 'menu_order',
12855 order: 'asc',
12856 _fields: 'id,title,parent'
12857 };
12858
12859 // Perform a search when the field is changed.
12860 if (!!fieldValue) {
12861 query.search = fieldValue;
12862 }
12863 const parentPost = pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null;
12864 return {
12865 isHierarchical: postIsHierarchical,
12866 parentPostId: pageId,
12867 parentPostTitle: parentPost ? getTitle(parentPost) : '',
12868 pageItems: postIsHierarchical ? getEntityRecords('postType', postTypeSlug, query) : null
12869 };
12870 }, [fieldValue]);
12871 const parentOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
12872 const getOptionsFromTree = (tree, level = 0) => {
12873 const mappedNodes = tree.map(treeNode => [{
12874 value: treeNode.id,
12875 label: '— '.repeat(level) + (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(treeNode.name),
12876 rawName: treeNode.name
12877 }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
12878 const sortedNodes = mappedNodes.sort(([a], [b]) => {
12879 const priorityA = getItemPriority(a.rawName, fieldValue);
12880 const priorityB = getItemPriority(b.rawName, fieldValue);
12881 return priorityA >= priorityB ? 1 : -1;
12882 });
12883 return sortedNodes.flat();
12884 };
12885 if (!pageItems) {
12886 return [];
12887 }
12888 let tree = pageItems.map(item => ({
12889 id: item.id,
12890 parent: item.parent,
12891 name: getTitle(item)
12892 }));
12893
12894 // Only build a hierarchical tree when not searching.
12895 if (!fieldValue) {
12896 tree = buildTermsTree(tree);
12897 }
12898 const opts = getOptionsFromTree(tree);
12899
12900 // Ensure the current parent is in the options list.
12901 const optsHasParent = opts.find(item => item.value === parentPostId);
12902 if (parentPostTitle && !optsHasParent) {
12903 opts.unshift({
12904 value: parentPostId,
12905 label: parentPostTitle
12906 });
12907 }
12908 return opts;
12909 }, [pageItems, fieldValue, parentPostTitle, parentPostId]);
12910 if (!isHierarchical) {
12911 return null;
12912 }
12913 /**
12914 * Handle user input.
12915 *
12916 * @param {string} inputValue The current value of the input field.
12917 */
12918 const handleKeydown = inputValue => {
12919 setFieldValue(inputValue);
12920 };
12921
12922 /**
12923 * Handle author selection.
12924 *
12925 * @param {Object} selectedPostId The selected Author.
12926 */
12927 const handleChange = selectedPostId => {
12928 editPost({
12929 parent: selectedPostId
12930 });
12931 };
12932 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
12933 __nextHasNoMarginBottom: true,
12934 __next40pxDefaultSize: true,
12935 className: "editor-page-attributes__parent",
12936 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
12937 help: (0,external_wp_i18n_namespaceObject.__)('Choose a parent page.'),
12938 value: parentPostId,
12939 options: parentOptions,
12940 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
12941 onChange: handleChange,
12942 hideLabelFromVision: true
12943 });
12944 }
12945 function PostParentToggle({
12946 isOpen,
12947 onClick
12948 }) {
12949 const parentPost = (0,external_wp_data_namespaceObject.useSelect)(select => {
12950 const {
12951 getEditedPostAttribute
12952 } = select(store_store);
12953 const parentPostId = getEditedPostAttribute('parent');
12954 if (!parentPostId) {
12955 return null;
12956 }
12957 const {
12958 getEntityRecord
12959 } = select(external_wp_coreData_namespaceObject.store);
12960 const postTypeSlug = getEditedPostAttribute('type');
12961 return getEntityRecord('postType', postTypeSlug, parentPostId);
12962 }, []);
12963 const parentTitle = (0,external_wp_element_namespaceObject.useMemo)(() => !parentPost ? (0,external_wp_i18n_namespaceObject.__)('None') : getTitle(parentPost), [parentPost]);
12964 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12965 size: "compact",
12966 className: "editor-post-parent__panel-toggle",
12967 variant: "tertiary",
12968 "aria-expanded": isOpen,
12969 "aria-label":
12970 // translators: %s: Current post parent.
12971 (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change parent: %s'), parentTitle),
12972 onClick: onClick,
12973 children: parentTitle
12974 });
12975 }
12976 function ParentRow() {
12977 const homeUrl = (0,external_wp_data_namespaceObject.useSelect)(select => {
12978 // Site index.
12979 return select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.home;
12980 }, []);
12981 // Use internal state instead of a ref to make sure that the component
12982 // re-renders when the popover's anchor updates.
12983 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
12984 // Memoize popoverProps to avoid returning a new object every time.
12985 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
12986 // Anchor the popover to the middle of the entire row so that it doesn't
12987 // move around when the label changes.
12988 anchor: popoverAnchor,
12989 placement: 'left-start',
12990 offset: 36,
12991 shift: true
12992 }), [popoverAnchor]);
12993 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
12994 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
12995 ref: setPopoverAnchor,
12996 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
12997 popoverProps: popoverProps,
12998 className: "editor-post-parent__panel-dropdown",
12999 contentClassName: "editor-post-parent__panel-dialog",
13000 focusOnMount: true,
13001 renderToggle: ({
13002 isOpen,
13003 onToggle
13004 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostParentToggle, {
13005 isOpen: isOpen,
13006 onClick: onToggle
13007 }),
13008 renderContent: ({
13009 onClose
13010 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13011 className: "editor-post-parent",
13012 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
13013 title: (0,external_wp_i18n_namespaceObject.__)('Parent'),
13014 onClose: onClose
13015 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13016 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. */
13017 (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')), {
13018 wbr: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("wbr", {})
13019 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13020 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>'), {
13021 a: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
13022 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes')
13023 })
13024 })
13025 })]
13026 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesParent, {})]
13027 })
13028 })
13029 });
13030 }
13031 /* harmony default export */ const page_attributes_parent = (PageAttributesParent);
13032
13033 ;// ./packages/editor/build-module/components/page-attributes/panel.js
13034 /**
13035 * WordPress dependencies
13036 */
13037
13038
13039 /**
13040 * Internal dependencies
13041 */
13042
13043
13044
13045
13046 const PANEL_NAME = 'page-attributes';
13047 function AttributesPanel() {
13048 const {
13049 isEnabled,
13050 postType
13051 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13052 const {
13053 getEditedPostAttribute,
13054 isEditorPanelEnabled
13055 } = select(store_store);
13056 const {
13057 getPostType
13058 } = select(external_wp_coreData_namespaceObject.store);
13059 return {
13060 isEnabled: isEditorPanelEnabled(PANEL_NAME),
13061 postType: getPostType(getEditedPostAttribute('type'))
13062 };
13063 }, []);
13064 if (!isEnabled || !postType) {
13065 return null;
13066 }
13067 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ParentRow, {});
13068 }
13069
13070 /**
13071 * Renders the Page Attributes Panel component.
13072 *
13073 * @return {Component} The component to be rendered.
13074 */
13075 function PageAttributesPanel() {
13076 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
13077 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AttributesPanel, {})
13078 });
13079 }
13080
13081 ;// ./packages/icons/build-module/library/add-template.js
13082 /**
13083 * WordPress dependencies
13084 */
13085
13086
13087 const addTemplate = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
13088 viewBox: "0 0 24 24",
13089 xmlns: "http://www.w3.org/2000/svg",
13090 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
13091 fillRule: "evenodd",
13092 clipRule: "evenodd",
13093 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"
13094 })
13095 });
13096 /* harmony default export */ const add_template = (addTemplate);
13097
13098 ;// ./packages/editor/build-module/components/post-template/create-new-template-modal.js
13099 /**
13100 * WordPress dependencies
13101 */
13102
13103
13104
13105
13106
13107
13108
13109 /**
13110 * Internal dependencies
13111 */
13112
13113
13114
13115 const DEFAULT_TITLE = (0,external_wp_i18n_namespaceObject.__)('Custom Template');
13116 function CreateNewTemplateModal({
13117 onClose
13118 }) {
13119 const {
13120 defaultBlockTemplate,
13121 onNavigateToEntityRecord
13122 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13123 const {
13124 getEditorSettings,
13125 getCurrentTemplateId
13126 } = select(store_store);
13127 return {
13128 defaultBlockTemplate: getEditorSettings().defaultBlockTemplate,
13129 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
13130 getTemplateId: getCurrentTemplateId
13131 };
13132 });
13133 const {
13134 createTemplate
13135 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
13136 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
13137 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
13138 const cancel = () => {
13139 setTitle('');
13140 onClose();
13141 };
13142 const submit = async event => {
13143 event.preventDefault();
13144 if (isBusy) {
13145 return;
13146 }
13147 setIsBusy(true);
13148 const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : (0,external_wp_blocks_namespaceObject.serialize)([(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
13149 tagName: 'header',
13150 layout: {
13151 inherit: true
13152 }
13153 }, [(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', {
13154 tagName: 'main'
13155 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
13156 layout: {
13157 inherit: true
13158 }
13159 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/post-title')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/post-content', {
13160 layout: {
13161 inherit: true
13162 }
13163 })])]);
13164 const newTemplate = await createTemplate({
13165 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(title || DEFAULT_TITLE),
13166 content: newTemplateContent,
13167 title: title || DEFAULT_TITLE
13168 });
13169 setIsBusy(false);
13170 onNavigateToEntityRecord({
13171 postId: newTemplate.id,
13172 postType: 'wp_template'
13173 });
13174 cancel();
13175 };
13176 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
13177 title: (0,external_wp_i18n_namespaceObject.__)('Create custom template'),
13178 onRequestClose: cancel,
13179 focusOnMount: "firstContentElement",
13180 size: "small",
13181 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
13182 className: "editor-post-template__create-form",
13183 onSubmit: submit,
13184 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
13185 spacing: "3",
13186 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
13187 __next40pxDefaultSize: true,
13188 __nextHasNoMarginBottom: true,
13189 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
13190 value: title,
13191 onChange: setTitle,
13192 placeholder: DEFAULT_TITLE,
13193 disabled: isBusy,
13194 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.')
13195 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
13196 justify: "right",
13197 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13198 __next40pxDefaultSize: true,
13199 variant: "tertiary",
13200 onClick: cancel,
13201 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
13202 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13203 __next40pxDefaultSize: true,
13204 variant: "primary",
13205 type: "submit",
13206 isBusy: isBusy,
13207 "aria-disabled": isBusy,
13208 children: (0,external_wp_i18n_namespaceObject.__)('Create')
13209 })]
13210 })]
13211 })
13212 })
13213 });
13214 }
13215
13216 ;// ./packages/editor/build-module/components/post-template/hooks.js
13217 /**
13218 * WordPress dependencies
13219 */
13220
13221
13222
13223
13224 /**
13225 * Internal dependencies
13226 */
13227
13228 function useEditedPostContext() {
13229 return (0,external_wp_data_namespaceObject.useSelect)(select => {
13230 const {
13231 getCurrentPostId,
13232 getCurrentPostType
13233 } = select(store_store);
13234 return {
13235 postId: getCurrentPostId(),
13236 postType: getCurrentPostType()
13237 };
13238 }, []);
13239 }
13240 function useAllowSwitchingTemplates() {
13241 const {
13242 postType,
13243 postId
13244 } = useEditedPostContext();
13245 return (0,external_wp_data_namespaceObject.useSelect)(select => {
13246 const {
13247 canUser,
13248 getEntityRecord,
13249 getEntityRecords
13250 } = select(external_wp_coreData_namespaceObject.store);
13251 const siteSettings = canUser('read', {
13252 kind: 'root',
13253 name: 'site'
13254 }) ? getEntityRecord('root', 'site') : undefined;
13255 const templates = getEntityRecords('postType', 'wp_template', {
13256 per_page: -1
13257 });
13258 const isPostsPage = +postId === siteSettings?.page_for_posts;
13259 // If current page is set front page or posts page, we also need
13260 // to check if the current theme has a template for it. If not
13261 const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({
13262 slug
13263 }) => slug === 'front-page');
13264 return !isPostsPage && !isFrontPage;
13265 }, [postId, postType]);
13266 }
13267 function useTemplates(postType) {
13268 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
13269 per_page: -1,
13270 post_type: postType
13271 }), [postType]);
13272 }
13273 function useAvailableTemplates(postType) {
13274 const currentTemplateSlug = useCurrentTemplateSlug();
13275 const allowSwitchingTemplate = useAllowSwitchingTemplates();
13276 const templates = useTemplates(postType);
13277 return (0,external_wp_element_namespaceObject.useMemo)(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
13278 ), [templates, currentTemplateSlug, allowSwitchingTemplate]);
13279 }
13280 function useCurrentTemplateSlug() {
13281 const {
13282 postType,
13283 postId
13284 } = useEditedPostContext();
13285 const templates = useTemplates(postType);
13286 const entityTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
13287 const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
13288 return post?.template;
13289 }, [postType, postId]);
13290 if (!entityTemplate) {
13291 return;
13292 }
13293 // If a page has a `template` set and is not included in the list
13294 // of the theme's templates, do not return it, in order to resolve
13295 // to the current theme's default template.
13296 return templates?.find(template => template.slug === entityTemplate)?.slug;
13297 }
13298
13299 ;// ./packages/editor/build-module/components/post-template/classic-theme.js
13300 /**
13301 * WordPress dependencies
13302 */
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312 /**
13313 * Internal dependencies
13314 */
13315
13316
13317
13318
13319 const POPOVER_PROPS = {
13320 className: 'editor-post-template__dropdown',
13321 placement: 'bottom-start'
13322 };
13323 function PostTemplateToggle({
13324 isOpen,
13325 onClick
13326 }) {
13327 const templateTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
13328 const templateSlug = select(store_store).getEditedPostAttribute('template');
13329 const {
13330 supportsTemplateMode,
13331 availableTemplates
13332 } = select(store_store).getEditorSettings();
13333 if (!supportsTemplateMode && availableTemplates[templateSlug]) {
13334 return availableTemplates[templateSlug];
13335 }
13336 const template = select(external_wp_coreData_namespaceObject.store).canUser('create', {
13337 kind: 'postType',
13338 name: 'wp_template'
13339 }) && select(store_store).getCurrentTemplateId();
13340 return template?.title || template?.slug || availableTemplates?.[templateSlug];
13341 }, []);
13342 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13343 __next40pxDefaultSize: true,
13344 variant: "tertiary",
13345 "aria-expanded": isOpen,
13346 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Template options'),
13347 onClick: onClick,
13348 children: templateTitle !== null && templateTitle !== void 0 ? templateTitle : (0,external_wp_i18n_namespaceObject.__)('Default template')
13349 });
13350 }
13351
13352 /**
13353 * Renders the dropdown content for selecting a post template.
13354 *
13355 * @param {Object} props The component props.
13356 * @param {Function} props.onClose The function to close the dropdown.
13357 *
13358 * @return {JSX.Element} The rendered dropdown content.
13359 */
13360 function PostTemplateDropdownContent({
13361 onClose
13362 }) {
13363 var _options$find, _selectedOption$value;
13364 const allowSwitchingTemplate = useAllowSwitchingTemplates();
13365 const {
13366 availableTemplates,
13367 fetchedTemplates,
13368 selectedTemplateSlug,
13369 canCreate,
13370 canEdit,
13371 currentTemplateId,
13372 onNavigateToEntityRecord,
13373 getEditorSettings
13374 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13375 const {
13376 canUser,
13377 getEntityRecords
13378 } = select(external_wp_coreData_namespaceObject.store);
13379 const editorSettings = select(store_store).getEditorSettings();
13380 const canCreateTemplates = canUser('create', {
13381 kind: 'postType',
13382 name: 'wp_template'
13383 });
13384 const _currentTemplateId = select(store_store).getCurrentTemplateId();
13385 return {
13386 availableTemplates: editorSettings.availableTemplates,
13387 fetchedTemplates: canCreateTemplates ? getEntityRecords('postType', 'wp_template', {
13388 post_type: select(store_store).getCurrentPostType(),
13389 per_page: -1
13390 }) : undefined,
13391 selectedTemplateSlug: select(store_store).getEditedPostAttribute('template'),
13392 canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode,
13393 canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!_currentTemplateId,
13394 currentTemplateId: _currentTemplateId,
13395 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
13396 getEditorSettings: select(store_store).getEditorSettings
13397 };
13398 }, [allowSwitchingTemplate]);
13399 const options = (0,external_wp_element_namespaceObject.useMemo)(() => Object.entries({
13400 ...availableTemplates,
13401 ...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({
13402 slug,
13403 title
13404 }) => [slug, title.rendered]))
13405 }).map(([slug, title]) => ({
13406 value: slug,
13407 label: title
13408 })), [availableTemplates, fetchedTemplates]);
13409 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.
13410
13411 const {
13412 editPost
13413 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13414 const {
13415 createSuccessNotice
13416 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
13417 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
13418 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13419 className: "editor-post-template__classic-theme-dropdown",
13420 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
13421 title: (0,external_wp_i18n_namespaceObject.__)('Template'),
13422 help: (0,external_wp_i18n_namespaceObject.__)('Templates define the way content is displayed when viewing your site.'),
13423 actions: canCreate ? [{
13424 icon: add_template,
13425 label: (0,external_wp_i18n_namespaceObject.__)('Add template'),
13426 onClick: () => setIsCreateModalOpen(true)
13427 }] : [],
13428 onClose: onClose
13429 }), !allowSwitchingTemplate ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
13430 status: "warning",
13431 isDismissible: false,
13432 children: (0,external_wp_i18n_namespaceObject.__)('The posts page template cannot be changed.')
13433 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
13434 __next40pxDefaultSize: true,
13435 __nextHasNoMarginBottom: true,
13436 hideLabelFromVision: true,
13437 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
13438 value: (_selectedOption$value = selectedOption?.value) !== null && _selectedOption$value !== void 0 ? _selectedOption$value : '',
13439 options: options,
13440 onChange: slug => editPost({
13441 template: slug || ''
13442 })
13443 }), canEdit && onNavigateToEntityRecord && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13444 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13445 __next40pxDefaultSize: true,
13446 variant: "link",
13447 onClick: () => {
13448 onNavigateToEntityRecord({
13449 postId: currentTemplateId,
13450 postType: 'wp_template'
13451 });
13452 onClose();
13453 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
13454 type: 'snackbar',
13455 actions: [{
13456 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
13457 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
13458 }]
13459 });
13460 },
13461 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
13462 })
13463 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
13464 onClose: () => setIsCreateModalOpen(false)
13465 })]
13466 });
13467 }
13468 function ClassicThemeControl() {
13469 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
13470 popoverProps: POPOVER_PROPS,
13471 focusOnMount: true,
13472 renderToggle: ({
13473 isOpen,
13474 onToggle
13475 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateToggle, {
13476 isOpen: isOpen,
13477 onClick: onToggle
13478 }),
13479 renderContent: ({
13480 onClose
13481 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateDropdownContent, {
13482 onClose: onClose
13483 })
13484 });
13485 }
13486
13487 /**
13488 * Provides a dropdown menu for selecting and managing post templates.
13489 *
13490 * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.
13491 *
13492 * @return {JSX.Element} The rendered ClassicThemeControl component.
13493 */
13494 /* harmony default export */ const classic_theme = (ClassicThemeControl);
13495
13496 ;// external ["wp","warning"]
13497 const external_wp_warning_namespaceObject = window["wp"]["warning"];
13498 ;// ./packages/editor/build-module/components/preferences-modal/enable-panel.js
13499 /**
13500 * WordPress dependencies
13501 */
13502
13503
13504
13505
13506 /**
13507 * Internal dependencies
13508 */
13509
13510
13511 const {
13512 PreferenceBaseOption
13513 } = unlock(external_wp_preferences_namespaceObject.privateApis);
13514 /* harmony default export */ const enable_panel = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, {
13515 panelName
13516 }) => {
13517 const {
13518 isEditorPanelEnabled,
13519 isEditorPanelRemoved
13520 } = select(store_store);
13521 return {
13522 isRemoved: isEditorPanelRemoved(panelName),
13523 isChecked: isEditorPanelEnabled(panelName)
13524 };
13525 }), (0,external_wp_compose_namespaceObject.ifCondition)(({
13526 isRemoved
13527 }) => !isRemoved), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
13528 panelName
13529 }) => ({
13530 onChange: () => dispatch(store_store).toggleEditorPanelEnabled(panelName)
13531 })))(PreferenceBaseOption));
13532
13533 ;// ./packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js
13534 /**
13535 * WordPress dependencies
13536 */
13537
13538
13539 /**
13540 * Internal dependencies
13541 */
13542
13543
13544 const {
13545 Fill,
13546 Slot
13547 } = (0,external_wp_components_namespaceObject.createSlotFill)('EnablePluginDocumentSettingPanelOption');
13548 const EnablePluginDocumentSettingPanelOption = ({
13549 label,
13550 panelName
13551 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Fill, {
13552 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
13553 label: label,
13554 panelName: panelName
13555 })
13556 });
13557 EnablePluginDocumentSettingPanelOption.Slot = Slot;
13558 /* harmony default export */ const enable_plugin_document_setting_panel = (EnablePluginDocumentSettingPanelOption);
13559
13560 ;// ./packages/editor/build-module/components/plugin-document-setting-panel/index.js
13561 /**
13562 * WordPress dependencies
13563 */
13564
13565
13566
13567
13568
13569 /**
13570 * Internal dependencies
13571 */
13572
13573
13574
13575 const {
13576 Fill: plugin_document_setting_panel_Fill,
13577 Slot: plugin_document_setting_panel_Slot
13578 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginDocumentSettingPanel');
13579
13580 /**
13581 * Renders items below the Status & Availability panel in the Document Sidebar.
13582 *
13583 * @param {Object} props Component properties.
13584 * @param {string} props.name Required. A machine-friendly name for the panel.
13585 * @param {string} [props.className] An optional class name added to the row.
13586 * @param {string} [props.title] The title of the panel
13587 * @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.
13588 * @param {Element} props.children Children to be rendered
13589 *
13590 * @example
13591 * ```js
13592 * // Using ES5 syntax
13593 * var el = React.createElement;
13594 * var __ = wp.i18n.__;
13595 * var registerPlugin = wp.plugins.registerPlugin;
13596 * var PluginDocumentSettingPanel = wp.editor.PluginDocumentSettingPanel;
13597 *
13598 * function MyDocumentSettingPlugin() {
13599 * return el(
13600 * PluginDocumentSettingPanel,
13601 * {
13602 * className: 'my-document-setting-plugin',
13603 * title: 'My Panel',
13604 * name: 'my-panel',
13605 * },
13606 * __( 'My Document Setting Panel' )
13607 * );
13608 * }
13609 *
13610 * registerPlugin( 'my-document-setting-plugin', {
13611 * render: MyDocumentSettingPlugin
13612 * } );
13613 * ```
13614 *
13615 * @example
13616 * ```jsx
13617 * // Using ESNext syntax
13618 * import { registerPlugin } from '@wordpress/plugins';
13619 * import { PluginDocumentSettingPanel } from '@wordpress/editor';
13620 *
13621 * const MyDocumentSettingTest = () => (
13622 * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
13623 * <p>My Document Setting Panel</p>
13624 * </PluginDocumentSettingPanel>
13625 * );
13626 *
13627 * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
13628 * ```
13629 *
13630 * @return {Component} The component to be rendered.
13631 */
13632 const PluginDocumentSettingPanel = ({
13633 name,
13634 className,
13635 title,
13636 icon,
13637 children
13638 }) => {
13639 const {
13640 name: pluginName
13641 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
13642 const panelName = `${pluginName}/${name}`;
13643 const {
13644 opened,
13645 isEnabled
13646 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13647 const {
13648 isEditorPanelOpened,
13649 isEditorPanelEnabled
13650 } = select(store_store);
13651 return {
13652 opened: isEditorPanelOpened(panelName),
13653 isEnabled: isEditorPanelEnabled(panelName)
13654 };
13655 }, [panelName]);
13656 const {
13657 toggleEditorPanelOpened
13658 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13659 if (undefined === name) {
13660 false ? 0 : void 0;
13661 }
13662 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13663 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel, {
13664 label: title,
13665 panelName: panelName
13666 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_document_setting_panel_Fill, {
13667 children: isEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
13668 className: className,
13669 title: title,
13670 icon: icon,
13671 opened: opened,
13672 onToggle: () => toggleEditorPanelOpened(panelName),
13673 children: children
13674 })
13675 })]
13676 });
13677 };
13678 PluginDocumentSettingPanel.Slot = plugin_document_setting_panel_Slot;
13679 /* harmony default export */ const plugin_document_setting_panel = (PluginDocumentSettingPanel);
13680
13681 ;// ./packages/editor/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js
13682 /**
13683 * WordPress dependencies
13684 */
13685
13686
13687
13688
13689 const isEverySelectedBlockAllowed = (selected, allowed) => selected.filter(id => !allowed.includes(id)).length === 0;
13690
13691 /**
13692 * Plugins may want to add an item to the menu either for every block
13693 * or only for the specific ones provided in the `allowedBlocks` component property.
13694 *
13695 * If there are multiple blocks selected the item will be rendered if every block
13696 * is of one allowed type (not necessarily the same).
13697 *
13698 * @param {string[]} selectedBlocks Array containing the names of the blocks selected
13699 * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
13700 * @return {boolean} Whether the item will be rendered or not.
13701 */
13702 const shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
13703
13704 /**
13705 * Renders a new item in the block settings menu.
13706 *
13707 * @param {Object} props Component props.
13708 * @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.
13709 * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
13710 * @param {string} props.label The menu item text.
13711 * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
13712 * @param {boolean} [props.small] Whether to render the label or not.
13713 * @param {string} [props.role] The ARIA role for the menu item.
13714 *
13715 * @example
13716 * ```js
13717 * // Using ES5 syntax
13718 * var __ = wp.i18n.__;
13719 * var PluginBlockSettingsMenuItem = wp.editor.PluginBlockSettingsMenuItem;
13720 *
13721 * function doOnClick(){
13722 * // To be called when the user clicks the menu item.
13723 * }
13724 *
13725 * function MyPluginBlockSettingsMenuItem() {
13726 * return React.createElement(
13727 * PluginBlockSettingsMenuItem,
13728 * {
13729 * allowedBlocks: [ 'core/paragraph' ],
13730 * icon: 'dashicon-name',
13731 * label: __( 'Menu item text' ),
13732 * onClick: doOnClick,
13733 * }
13734 * );
13735 * }
13736 * ```
13737 *
13738 * @example
13739 * ```jsx
13740 * // Using ESNext syntax
13741 * import { __ } from '@wordpress/i18n';
13742 * import { PluginBlockSettingsMenuItem } from '@wordpress/editor';
13743 *
13744 * const doOnClick = ( ) => {
13745 * // To be called when the user clicks the menu item.
13746 * };
13747 *
13748 * const MyPluginBlockSettingsMenuItem = () => (
13749 * <PluginBlockSettingsMenuItem
13750 * allowedBlocks={ [ 'core/paragraph' ] }
13751 * icon='dashicon-name'
13752 * label={ __( 'Menu item text' ) }
13753 * onClick={ doOnClick } />
13754 * );
13755 * ```
13756 *
13757 * @return {Component} The component to be rendered.
13758 */
13759 const PluginBlockSettingsMenuItem = ({
13760 allowedBlocks,
13761 icon,
13762 label,
13763 onClick,
13764 small,
13765 role
13766 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
13767 children: ({
13768 selectedBlocks,
13769 onClose
13770 }) => {
13771 if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
13772 return null;
13773 }
13774 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
13775 onClick: (0,external_wp_compose_namespaceObject.compose)(onClick, onClose),
13776 icon: icon,
13777 label: small ? label : undefined,
13778 role: role,
13779 children: !small && label
13780 });
13781 }
13782 });
13783 /* harmony default export */ const plugin_block_settings_menu_item = (PluginBlockSettingsMenuItem);
13784
13785 ;// ./packages/editor/build-module/components/plugin-more-menu-item/index.js
13786 /**
13787 * WordPress dependencies
13788 */
13789
13790
13791
13792
13793 /**
13794 * 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.
13795 * The text within the component appears as the menu item label.
13796 *
13797 * @param {Object} props Component properties.
13798 * @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.
13799 * @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.
13800 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
13801 * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.
13802 *
13803 * @example
13804 * ```js
13805 * // Using ES5 syntax
13806 * var __ = wp.i18n.__;
13807 * var PluginMoreMenuItem = wp.editor.PluginMoreMenuItem;
13808 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
13809 *
13810 * function onButtonClick() {
13811 * alert( 'Button clicked.' );
13812 * }
13813 *
13814 * function MyButtonMoreMenuItem() {
13815 * return wp.element.createElement(
13816 * PluginMoreMenuItem,
13817 * {
13818 * icon: moreIcon,
13819 * onClick: onButtonClick,
13820 * },
13821 * __( 'My button title' )
13822 * );
13823 * }
13824 * ```
13825 *
13826 * @example
13827 * ```jsx
13828 * // Using ESNext syntax
13829 * import { __ } from '@wordpress/i18n';
13830 * import { PluginMoreMenuItem } from '@wordpress/editor';
13831 * import { more } from '@wordpress/icons';
13832 *
13833 * function onButtonClick() {
13834 * alert( 'Button clicked.' );
13835 * }
13836 *
13837 * const MyButtonMoreMenuItem = () => (
13838 * <PluginMoreMenuItem
13839 * icon={ more }
13840 * onClick={ onButtonClick }
13841 * >
13842 * { __( 'My button title' ) }
13843 * </PluginMoreMenuItem>
13844 * );
13845 * ```
13846 *
13847 * @return {Component} The component to be rendered.
13848 */
13849
13850 function PluginMoreMenuItem(props) {
13851 var _props$as;
13852 const context = (0,external_wp_plugins_namespaceObject.usePluginContext)();
13853 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item, {
13854 name: "core/plugin-more-menu",
13855 as: (_props$as = props.as) !== null && _props$as !== void 0 ? _props$as : external_wp_components_namespaceObject.MenuItem,
13856 icon: props.icon || context.icon,
13857 ...props
13858 });
13859 }
13860
13861 ;// ./packages/editor/build-module/components/plugin-post-publish-panel/index.js
13862 /**
13863 * WordPress dependencies
13864 */
13865
13866
13867
13868 const {
13869 Fill: plugin_post_publish_panel_Fill,
13870 Slot: plugin_post_publish_panel_Slot
13871 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostPublishPanel');
13872
13873 /**
13874 * Renders provided content to the post-publish panel in the publish flow
13875 * (side panel that opens after a user publishes the post).
13876 *
13877 * @param {Object} props Component properties.
13878 * @param {string} [props.className] An optional class name added to the panel.
13879 * @param {string} [props.title] Title displayed at the top of the panel.
13880 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened.
13881 * @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.
13882 * @param {Element} props.children Children to be rendered
13883 *
13884 * @example
13885 * ```jsx
13886 * // Using ESNext syntax
13887 * import { __ } from '@wordpress/i18n';
13888 * import { PluginPostPublishPanel } from '@wordpress/editor';
13889 *
13890 * const MyPluginPostPublishPanel = () => (
13891 * <PluginPostPublishPanel
13892 * className="my-plugin-post-publish-panel"
13893 * title={ __( 'My panel title' ) }
13894 * initialOpen={ true }
13895 * >
13896 * { __( 'My panel content' ) }
13897 * </PluginPostPublishPanel>
13898 * );
13899 * ```
13900 *
13901 * @return {Component} The component to be rendered.
13902 */
13903 const PluginPostPublishPanel = ({
13904 children,
13905 className,
13906 title,
13907 initialOpen = false,
13908 icon
13909 }) => {
13910 const {
13911 icon: pluginIcon
13912 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
13913 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_publish_panel_Fill, {
13914 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
13915 className: className,
13916 initialOpen: initialOpen || !title,
13917 title: title,
13918 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
13919 children: children
13920 })
13921 });
13922 };
13923 PluginPostPublishPanel.Slot = plugin_post_publish_panel_Slot;
13924 /* harmony default export */ const plugin_post_publish_panel = (PluginPostPublishPanel);
13925
13926 ;// ./packages/editor/build-module/components/plugin-post-status-info/index.js
13927 /**
13928 * Defines as extensibility slot for the Summary panel.
13929 */
13930
13931 /**
13932 * WordPress dependencies
13933 */
13934
13935
13936 const {
13937 Fill: plugin_post_status_info_Fill,
13938 Slot: plugin_post_status_info_Slot
13939 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostStatusInfo');
13940
13941 /**
13942 * Renders a row in the Summary panel of the Document sidebar.
13943 * It should be noted that this is named and implemented around the function it serves
13944 * and not its location, which may change in future iterations.
13945 *
13946 * @param {Object} props Component properties.
13947 * @param {string} [props.className] An optional class name added to the row.
13948 * @param {Element} props.children Children to be rendered.
13949 *
13950 * @example
13951 * ```js
13952 * // Using ES5 syntax
13953 * var __ = wp.i18n.__;
13954 * var PluginPostStatusInfo = wp.editor.PluginPostStatusInfo;
13955 *
13956 * function MyPluginPostStatusInfo() {
13957 * return React.createElement(
13958 * PluginPostStatusInfo,
13959 * {
13960 * className: 'my-plugin-post-status-info',
13961 * },
13962 * __( 'My post status info' )
13963 * )
13964 * }
13965 * ```
13966 *
13967 * @example
13968 * ```jsx
13969 * // Using ESNext syntax
13970 * import { __ } from '@wordpress/i18n';
13971 * import { PluginPostStatusInfo } from '@wordpress/editor';
13972 *
13973 * const MyPluginPostStatusInfo = () => (
13974 * <PluginPostStatusInfo
13975 * className="my-plugin-post-status-info"
13976 * >
13977 * { __( 'My post status info' ) }
13978 * </PluginPostStatusInfo>
13979 * );
13980 * ```
13981 *
13982 * @return {Component} The component to be rendered.
13983 */
13984 const PluginPostStatusInfo = ({
13985 children,
13986 className
13987 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info_Fill, {
13988 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
13989 className: className,
13990 children: children
13991 })
13992 });
13993 PluginPostStatusInfo.Slot = plugin_post_status_info_Slot;
13994 /* harmony default export */ const plugin_post_status_info = (PluginPostStatusInfo);
13995
13996 ;// ./packages/editor/build-module/components/plugin-pre-publish-panel/index.js
13997 /**
13998 * WordPress dependencies
13999 */
14000
14001
14002
14003 const {
14004 Fill: plugin_pre_publish_panel_Fill,
14005 Slot: plugin_pre_publish_panel_Slot
14006 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPrePublishPanel');
14007
14008 /**
14009 * Renders provided content to the pre-publish side panel in the publish flow
14010 * (side panel that opens when a user first pushes "Publish" from the main editor).
14011 *
14012 * @param {Object} props Component props.
14013 * @param {string} [props.className] An optional class name added to the panel.
14014 * @param {string} [props.title] Title displayed at the top of the panel.
14015 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened.
14016 * When no title is provided it is always opened.
14017 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
14018 * icon slug string, or an SVG WP element, to be rendered when
14019 * the sidebar is pinned to toolbar.
14020 * @param {Element} props.children Children to be rendered
14021 *
14022 * @example
14023 * ```jsx
14024 * // Using ESNext syntax
14025 * import { __ } from '@wordpress/i18n';
14026 * import { PluginPrePublishPanel } from '@wordpress/editor';
14027 *
14028 * const MyPluginPrePublishPanel = () => (
14029 * <PluginPrePublishPanel
14030 * className="my-plugin-pre-publish-panel"
14031 * title={ __( 'My panel title' ) }
14032 * initialOpen={ true }
14033 * >
14034 * { __( 'My panel content' ) }
14035 * </PluginPrePublishPanel>
14036 * );
14037 * ```
14038 *
14039 * @return {Component} The component to be rendered.
14040 */
14041 const PluginPrePublishPanel = ({
14042 children,
14043 className,
14044 title,
14045 initialOpen = false,
14046 icon
14047 }) => {
14048 const {
14049 icon: pluginIcon
14050 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
14051 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_pre_publish_panel_Fill, {
14052 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
14053 className: className,
14054 initialOpen: initialOpen || !title,
14055 title: title,
14056 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
14057 children: children
14058 })
14059 });
14060 };
14061 PluginPrePublishPanel.Slot = plugin_pre_publish_panel_Slot;
14062 /* harmony default export */ const plugin_pre_publish_panel = (PluginPrePublishPanel);
14063
14064 ;// ./packages/editor/build-module/components/plugin-preview-menu-item/index.js
14065 /**
14066 * WordPress dependencies
14067 */
14068
14069
14070
14071
14072 /**
14073 * Renders a menu item in the Preview dropdown, which can be used as a button or link depending on the props provided.
14074 * The text within the component appears as the menu item label.
14075 *
14076 * @param {Object} props Component properties.
14077 * @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.
14078 * @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.
14079 * @param {Function} [props.onClick] The callback function to be executed when the user clicks the menu item.
14080 * @param {...*} [props.other] Any additional props are passed through to the underlying MenuItem component.
14081 *
14082 * @example
14083 * ```jsx
14084 * import { __ } from '@wordpress/i18n';
14085 * import { PluginPreviewMenuItem } from '@wordpress/editor';
14086 * import { external } from '@wordpress/icons';
14087 *
14088 * function onPreviewClick() {
14089 * // Handle preview action
14090 * }
14091 *
14092 * const ExternalPreviewMenuItem = () => (
14093 * <PluginPreviewMenuItem
14094 * icon={ external }
14095 * onClick={ onPreviewClick }
14096 * >
14097 * { __( 'Preview in new tab' ) }
14098 * </PluginPreviewMenuItem>
14099 * );
14100 * registerPlugin( 'external-preview-menu-item', {
14101 * render: ExternalPreviewMenuItem,
14102 * } );
14103 * ```
14104 *
14105 * @return {Component} The rendered menu item component.
14106 */
14107
14108 function PluginPreviewMenuItem(props) {
14109 var _props$as;
14110 const context = (0,external_wp_plugins_namespaceObject.usePluginContext)();
14111 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item, {
14112 name: "core/plugin-preview-menu",
14113 as: (_props$as = props.as) !== null && _props$as !== void 0 ? _props$as : external_wp_components_namespaceObject.MenuItem,
14114 icon: props.icon || context.icon,
14115 ...props
14116 });
14117 }
14118
14119 ;// ./packages/editor/build-module/components/plugin-sidebar/index.js
14120 /**
14121 * WordPress dependencies
14122 */
14123
14124
14125 /**
14126 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
14127 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.
14128 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:
14129 *
14130 * ```js
14131 * wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-name' );
14132 * ```
14133 *
14134 * @see PluginSidebarMoreMenuItem
14135 *
14136 * @param {Object} props Element props.
14137 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
14138 * @param {string} [props.className] An optional class name added to the sidebar body.
14139 * @param {string} props.title Title displayed at the top of the sidebar.
14140 * @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.
14141 * @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.
14142 *
14143 * @example
14144 * ```js
14145 * // Using ES5 syntax
14146 * var __ = wp.i18n.__;
14147 * var el = React.createElement;
14148 * var PanelBody = wp.components.PanelBody;
14149 * var PluginSidebar = wp.editor.PluginSidebar;
14150 * var moreIcon = React.createElement( 'svg' ); //... svg element.
14151 *
14152 * function MyPluginSidebar() {
14153 * return el(
14154 * PluginSidebar,
14155 * {
14156 * name: 'my-sidebar',
14157 * title: 'My sidebar title',
14158 * icon: moreIcon,
14159 * },
14160 * el(
14161 * PanelBody,
14162 * {},
14163 * __( 'My sidebar content' )
14164 * )
14165 * );
14166 * }
14167 * ```
14168 *
14169 * @example
14170 * ```jsx
14171 * // Using ESNext syntax
14172 * import { __ } from '@wordpress/i18n';
14173 * import { PanelBody } from '@wordpress/components';
14174 * import { PluginSidebar } from '@wordpress/editor';
14175 * import { more } from '@wordpress/icons';
14176 *
14177 * const MyPluginSidebar = () => (
14178 * <PluginSidebar
14179 * name="my-sidebar"
14180 * title="My sidebar title"
14181 * icon={ more }
14182 * >
14183 * <PanelBody>
14184 * { __( 'My sidebar content' ) }
14185 * </PanelBody>
14186 * </PluginSidebar>
14187 * );
14188 * ```
14189 */
14190
14191 function PluginSidebar({
14192 className,
14193 ...props
14194 }) {
14195 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area, {
14196 panelClassName: className,
14197 className: "editor-sidebar",
14198 scope: "core",
14199 ...props
14200 });
14201 }
14202
14203 ;// ./packages/editor/build-module/components/plugin-sidebar-more-menu-item/index.js
14204 /**
14205 * WordPress dependencies
14206 */
14207
14208
14209 /**
14210 * Renders a menu item in `Plugins` group in `More Menu` drop down,
14211 * and can be used to activate the corresponding `PluginSidebar` component.
14212 * The text within the component appears as the menu item label.
14213 *
14214 * @param {Object} props Component props.
14215 * @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.
14216 * @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.
14217 *
14218 * @example
14219 * ```js
14220 * // Using ES5 syntax
14221 * var __ = wp.i18n.__;
14222 * var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
14223 * var moreIcon = React.createElement( 'svg' ); //... svg element.
14224 *
14225 * function MySidebarMoreMenuItem() {
14226 * return React.createElement(
14227 * PluginSidebarMoreMenuItem,
14228 * {
14229 * target: 'my-sidebar',
14230 * icon: moreIcon,
14231 * },
14232 * __( 'My sidebar title' )
14233 * )
14234 * }
14235 * ```
14236 *
14237 * @example
14238 * ```jsx
14239 * // Using ESNext syntax
14240 * import { __ } from '@wordpress/i18n';
14241 * import { PluginSidebarMoreMenuItem } from '@wordpress/editor';
14242 * import { more } from '@wordpress/icons';
14243 *
14244 * const MySidebarMoreMenuItem = () => (
14245 * <PluginSidebarMoreMenuItem
14246 * target="my-sidebar"
14247 * icon={ more }
14248 * >
14249 * { __( 'My sidebar title' ) }
14250 * </PluginSidebarMoreMenuItem>
14251 * );
14252 * ```
14253 *
14254 * @return {Component} The component to be rendered.
14255 */
14256
14257 function PluginSidebarMoreMenuItem(props) {
14258 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem
14259 // Menu item is marked with unstable prop for backward compatibility.
14260 // @see https://github.com/WordPress/gutenberg/issues/14457
14261 , {
14262 __unstableExplicitMenuItem: true,
14263 scope: "core",
14264 ...props
14265 });
14266 }
14267
14268 ;// ./packages/editor/build-module/components/post-template/swap-template-button.js
14269 /**
14270 * WordPress dependencies
14271 */
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282 /**
14283 * Internal dependencies
14284 */
14285
14286
14287 function SwapTemplateButton({
14288 onClick
14289 }) {
14290 const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false);
14291 const {
14292 postType,
14293 postId
14294 } = useEditedPostContext();
14295 const availableTemplates = useAvailableTemplates(postType);
14296 const {
14297 editEntityRecord
14298 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
14299 if (!availableTemplates?.length) {
14300 return null;
14301 }
14302 const onTemplateSelect = async template => {
14303 editEntityRecord('postType', postType, postId, {
14304 template: template.name
14305 }, {
14306 undoIgnore: true
14307 });
14308 setShowModal(false); // Close the template suggestions modal first.
14309 onClick();
14310 };
14311 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
14312 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
14313 onClick: () => setShowModal(true),
14314 children: (0,external_wp_i18n_namespaceObject.__)('Swap template')
14315 }), showModal && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
14316 title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'),
14317 onRequestClose: () => setShowModal(false),
14318 overlayClassName: "editor-post-template__swap-template-modal",
14319 isFullScreen: true,
14320 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
14321 className: "editor-post-template__swap-template-modal-content",
14322 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatesList, {
14323 postType: postType,
14324 onSelect: onTemplateSelect
14325 })
14326 })
14327 })]
14328 });
14329 }
14330 function TemplatesList({
14331 postType,
14332 onSelect
14333 }) {
14334 const availableTemplates = useAvailableTemplates(postType);
14335 const templatesAsPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => availableTemplates.map(template => ({
14336 name: template.slug,
14337 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content.raw),
14338 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered),
14339 id: template.id
14340 })), [availableTemplates]);
14341 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(templatesAsPatterns);
14342 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
14343 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
14344 blockPatterns: templatesAsPatterns,
14345 shownPatterns: shownTemplates,
14346 onClickPattern: onSelect
14347 });
14348 }
14349
14350 ;// ./packages/editor/build-module/components/post-template/reset-default-template.js
14351 /**
14352 * WordPress dependencies
14353 */
14354
14355
14356
14357
14358
14359 /**
14360 * Internal dependencies
14361 */
14362
14363
14364 function ResetDefaultTemplate({
14365 onClick
14366 }) {
14367 const currentTemplateSlug = useCurrentTemplateSlug();
14368 const allowSwitchingTemplate = useAllowSwitchingTemplates();
14369 const {
14370 postType,
14371 postId
14372 } = useEditedPostContext();
14373 const {
14374 editEntityRecord
14375 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
14376 // The default template in a post is indicated by an empty string.
14377 if (!currentTemplateSlug || !allowSwitchingTemplate) {
14378 return null;
14379 }
14380 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
14381 onClick: () => {
14382 editEntityRecord('postType', postType, postId, {
14383 template: ''
14384 }, {
14385 undoIgnore: true
14386 });
14387 onClick();
14388 },
14389 children: (0,external_wp_i18n_namespaceObject.__)('Use default template')
14390 });
14391 }
14392
14393 ;// ./packages/editor/build-module/components/post-template/create-new-template.js
14394 /**
14395 * WordPress dependencies
14396 */
14397
14398
14399
14400
14401
14402
14403 /**
14404 * Internal dependencies
14405 */
14406
14407
14408
14409 function CreateNewTemplate({
14410 onClick
14411 }) {
14412 const {
14413 canCreateTemplates
14414 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14415 const {
14416 canUser
14417 } = select(external_wp_coreData_namespaceObject.store);
14418 return {
14419 canCreateTemplates: canUser('create', {
14420 kind: 'postType',
14421 name: 'wp_template'
14422 })
14423 };
14424 }, []);
14425 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
14426 const allowSwitchingTemplate = useAllowSwitchingTemplates();
14427
14428 // The default template in a post is indicated by an empty string.
14429 if (!canCreateTemplates || !allowSwitchingTemplate) {
14430 return null;
14431 }
14432 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
14433 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
14434 onClick: () => {
14435 setIsCreateModalOpen(true);
14436 },
14437 children: (0,external_wp_i18n_namespaceObject.__)('Create new template')
14438 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
14439 onClose: () => {
14440 setIsCreateModalOpen(false);
14441 onClick();
14442 }
14443 })]
14444 });
14445 }
14446
14447 ;// ./packages/editor/build-module/components/post-template/block-theme.js
14448 /**
14449 * WordPress dependencies
14450 */
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460 /**
14461 * Internal dependencies
14462 */
14463
14464
14465
14466
14467
14468
14469 const block_theme_POPOVER_PROPS = {
14470 className: 'editor-post-template__dropdown',
14471 placement: 'bottom-start'
14472 };
14473 function BlockThemeControl({
14474 id
14475 }) {
14476 const {
14477 isTemplateHidden,
14478 onNavigateToEntityRecord,
14479 getEditorSettings,
14480 hasGoBack
14481 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14482 const {
14483 getRenderingMode,
14484 getEditorSettings: _getEditorSettings
14485 } = unlock(select(store_store));
14486 const editorSettings = _getEditorSettings();
14487 return {
14488 isTemplateHidden: getRenderingMode() === 'post-only',
14489 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
14490 getEditorSettings: _getEditorSettings,
14491 hasGoBack: editorSettings.hasOwnProperty('onNavigateToPreviousEntityRecord')
14492 };
14493 }, []);
14494 const {
14495 get: getPreference
14496 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_preferences_namespaceObject.store);
14497 const {
14498 editedRecord: template,
14499 hasResolved
14500 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'wp_template', id);
14501 const {
14502 createSuccessNotice
14503 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
14504 const {
14505 setRenderingMode
14506 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14507 const canCreateTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_coreData_namespaceObject.store).canUser('create', {
14508 kind: 'postType',
14509 name: 'wp_template'
14510 }), []);
14511 if (!hasResolved) {
14512 return null;
14513 }
14514
14515 // The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing
14516 // and assigns its own backlink to focusMode pages.
14517 const notificationAction = hasGoBack ? [{
14518 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
14519 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
14520 }] : undefined;
14521 const mayShowTemplateEditNotice = () => {
14522 if (!getPreference('core/edit-site', 'welcomeGuideTemplate')) {
14523 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
14524 type: 'snackbar',
14525 actions: notificationAction
14526 });
14527 }
14528 };
14529 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
14530 popoverProps: block_theme_POPOVER_PROPS,
14531 focusOnMount: true,
14532 toggleProps: {
14533 size: 'compact',
14534 variant: 'tertiary',
14535 tooltipPosition: 'middle left'
14536 },
14537 label: (0,external_wp_i18n_namespaceObject.__)('Template options'),
14538 text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title),
14539 icon: null,
14540 children: ({
14541 onClose
14542 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
14543 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
14544 children: [canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
14545 onClick: () => {
14546 onNavigateToEntityRecord({
14547 postId: template.id,
14548 postType: 'wp_template'
14549 });
14550 onClose();
14551 mayShowTemplateEditNotice();
14552 },
14553 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
14554 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SwapTemplateButton, {
14555 onClick: onClose
14556 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetDefaultTemplate, {
14557 onClick: onClose
14558 }), canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplate, {
14559 onClick: onClose
14560 })]
14561 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
14562 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
14563 icon: !isTemplateHidden ? library_check : undefined,
14564 isSelected: !isTemplateHidden,
14565 role: "menuitemcheckbox",
14566 onClick: () => {
14567 setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
14568 },
14569 children: (0,external_wp_i18n_namespaceObject.__)('Show template')
14570 })
14571 })]
14572 })
14573 });
14574 }
14575
14576 ;// ./packages/editor/build-module/components/post-template/panel.js
14577 /**
14578 * WordPress dependencies
14579 */
14580
14581
14582
14583
14584 /**
14585 * Internal dependencies
14586 */
14587
14588
14589
14590
14591
14592 /**
14593 * Displays the template controls based on the current editor settings and user permissions.
14594 *
14595 * @return {JSX.Element|null} The rendered PostTemplatePanel component.
14596 */
14597
14598 function PostTemplatePanel() {
14599 const {
14600 templateId,
14601 isBlockTheme
14602 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14603 const {
14604 getCurrentTemplateId,
14605 getEditorSettings
14606 } = select(store_store);
14607 return {
14608 templateId: getCurrentTemplateId(),
14609 isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme
14610 };
14611 }, []);
14612 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
14613 var _select$canUser;
14614 const postTypeSlug = select(store_store).getCurrentPostType();
14615 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
14616 if (!postType?.viewable) {
14617 return false;
14618 }
14619 const settings = select(store_store).getEditorSettings();
14620 const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
14621 if (hasTemplates) {
14622 return true;
14623 }
14624 if (!settings.supportsTemplateMode) {
14625 return false;
14626 }
14627 const canCreateTemplates = (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', {
14628 kind: 'postType',
14629 name: 'wp_template'
14630 })) !== null && _select$canUser !== void 0 ? _select$canUser : false;
14631 return canCreateTemplates;
14632 }, []);
14633 const canViewTemplates = (0,external_wp_data_namespaceObject.useSelect)(select => {
14634 var _select$canUser2;
14635 return (_select$canUser2 = select(external_wp_coreData_namespaceObject.store).canUser('read', {
14636 kind: 'postType',
14637 name: 'wp_template'
14638 })) !== null && _select$canUser2 !== void 0 ? _select$canUser2 : false;
14639 }, []);
14640 if ((!isBlockTheme || !canViewTemplates) && isVisible) {
14641 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
14642 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
14643 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(classic_theme, {})
14644 });
14645 }
14646 if (isBlockTheme && !!templateId) {
14647 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
14648 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
14649 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockThemeControl, {
14650 id: templateId
14651 })
14652 });
14653 }
14654 return null;
14655 }
14656
14657 ;// ./packages/editor/build-module/components/post-author/constants.js
14658 const BASE_QUERY = {
14659 _fields: 'id,name',
14660 context: 'view' // Allows non-admins to perform requests.
14661 };
14662 const AUTHORS_QUERY = {
14663 who: 'authors',
14664 per_page: 50,
14665 ...BASE_QUERY
14666 };
14667
14668 ;// ./packages/editor/build-module/components/post-author/hook.js
14669 /**
14670 * WordPress dependencies
14671 */
14672
14673
14674
14675
14676
14677
14678 /**
14679 * Internal dependencies
14680 */
14681
14682
14683 function useAuthorsQuery(search) {
14684 const {
14685 authorId,
14686 authors,
14687 postAuthor
14688 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14689 const {
14690 getUser,
14691 getUsers
14692 } = select(external_wp_coreData_namespaceObject.store);
14693 const {
14694 getEditedPostAttribute
14695 } = select(store_store);
14696 const _authorId = getEditedPostAttribute('author');
14697 const query = {
14698 ...AUTHORS_QUERY
14699 };
14700 if (search) {
14701 query.search = search;
14702 }
14703 return {
14704 authorId: _authorId,
14705 authors: getUsers(query),
14706 postAuthor: getUser(_authorId, BASE_QUERY)
14707 };
14708 }, [search]);
14709 const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
14710 const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
14711 return {
14712 value: author.id,
14713 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name)
14714 };
14715 });
14716
14717 // Ensure the current author is included in the dropdown list.
14718 const foundAuthor = fetchedAuthors.findIndex(({
14719 value
14720 }) => postAuthor?.id === value);
14721 let currentAuthor = [];
14722 if (foundAuthor < 0 && postAuthor) {
14723 currentAuthor = [{
14724 value: postAuthor.id,
14725 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor.name)
14726 }];
14727 } else if (foundAuthor < 0 && !postAuthor) {
14728 currentAuthor = [{
14729 value: 0,
14730 label: (0,external_wp_i18n_namespaceObject.__)('(No author)')
14731 }];
14732 }
14733 return [...currentAuthor, ...fetchedAuthors];
14734 }, [authors, postAuthor]);
14735 return {
14736 authorId,
14737 authorOptions,
14738 postAuthor
14739 };
14740 }
14741
14742 ;// ./packages/editor/build-module/components/post-author/combobox.js
14743 /**
14744 * WordPress dependencies
14745 */
14746
14747
14748
14749
14750
14751
14752 /**
14753 * Internal dependencies
14754 */
14755
14756
14757
14758 function PostAuthorCombobox() {
14759 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)();
14760 const {
14761 editPost
14762 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14763 const {
14764 authorId,
14765 authorOptions
14766 } = useAuthorsQuery(fieldValue);
14767
14768 /**
14769 * Handle author selection.
14770 *
14771 * @param {number} postAuthorId The selected Author.
14772 */
14773 const handleSelect = postAuthorId => {
14774 if (!postAuthorId) {
14775 return;
14776 }
14777 editPost({
14778 author: postAuthorId
14779 });
14780 };
14781
14782 /**
14783 * Handle user input.
14784 *
14785 * @param {string} inputValue The current value of the input field.
14786 */
14787 const handleKeydown = inputValue => {
14788 setFieldValue(inputValue);
14789 };
14790 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
14791 __nextHasNoMarginBottom: true,
14792 __next40pxDefaultSize: true,
14793 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
14794 options: authorOptions,
14795 value: authorId,
14796 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
14797 onChange: handleSelect,
14798 allowReset: false,
14799 hideLabelFromVision: true
14800 });
14801 }
14802
14803 ;// ./packages/editor/build-module/components/post-author/select.js
14804 /**
14805 * WordPress dependencies
14806 */
14807
14808
14809
14810
14811 /**
14812 * Internal dependencies
14813 */
14814
14815
14816
14817 function PostAuthorSelect() {
14818 const {
14819 editPost
14820 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14821 const {
14822 authorId,
14823 authorOptions
14824 } = useAuthorsQuery();
14825 const setAuthorId = value => {
14826 const author = Number(value);
14827 editPost({
14828 author
14829 });
14830 };
14831 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
14832 __next40pxDefaultSize: true,
14833 __nextHasNoMarginBottom: true,
14834 className: "post-author-selector",
14835 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
14836 options: authorOptions,
14837 onChange: setAuthorId,
14838 value: authorId,
14839 hideLabelFromVision: true
14840 });
14841 }
14842
14843 ;// ./packages/editor/build-module/components/post-author/index.js
14844 /**
14845 * WordPress dependencies
14846 */
14847
14848
14849
14850 /**
14851 * Internal dependencies
14852 */
14853
14854
14855
14856
14857 const minimumUsersForCombobox = 25;
14858
14859 /**
14860 * Renders the component for selecting the post author.
14861 *
14862 * @return {Component} The component to be rendered.
14863 */
14864 function PostAuthor() {
14865 const showCombobox = (0,external_wp_data_namespaceObject.useSelect)(select => {
14866 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
14867 return authors?.length >= minimumUsersForCombobox;
14868 }, []);
14869 if (showCombobox) {
14870 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCombobox, {});
14871 }
14872 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorSelect, {});
14873 }
14874 /* harmony default export */ const post_author = (PostAuthor);
14875
14876 ;// ./packages/editor/build-module/components/post-author/check.js
14877 /**
14878 * WordPress dependencies
14879 */
14880
14881
14882
14883 /**
14884 * Internal dependencies
14885 */
14886
14887
14888
14889
14890 /**
14891 * Wrapper component that renders its children only if the post type supports the author.
14892 *
14893 * @param {Object} props The component props.
14894 * @param {Element} props.children Children to be rendered.
14895 *
14896 * @return {Component|null} The component to be rendered. Return `null` if the post type doesn't
14897 * supports the author or if there are no authors available.
14898 */
14899
14900 function PostAuthorCheck({
14901 children
14902 }) {
14903 const {
14904 hasAssignAuthorAction,
14905 hasAuthors
14906 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14907 var _post$_links$wpActio;
14908 const post = select(store_store).getCurrentPost();
14909 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
14910 return {
14911 hasAssignAuthorAction: (_post$_links$wpActio = post._links?.['wp:action-assign-author']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
14912 hasAuthors: authors?.length >= 1
14913 };
14914 }, []);
14915 if (!hasAssignAuthorAction || !hasAuthors) {
14916 return null;
14917 }
14918 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
14919 supportKeys: "author",
14920 children: children
14921 });
14922 }
14923
14924 ;// ./packages/editor/build-module/components/post-author/panel.js
14925 /**
14926 * WordPress dependencies
14927 */
14928
14929
14930
14931
14932
14933
14934 /**
14935 * Internal dependencies
14936 */
14937
14938
14939
14940
14941
14942 function PostAuthorToggle({
14943 isOpen,
14944 onClick
14945 }) {
14946 const {
14947 postAuthor
14948 } = useAuthorsQuery();
14949 const authorName = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor?.name) || (0,external_wp_i18n_namespaceObject.__)('(No author)');
14950 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
14951 size: "compact",
14952 className: "editor-post-author__panel-toggle",
14953 variant: "tertiary",
14954 "aria-expanded": isOpen,
14955 "aria-label":
14956 // translators: %s: Author name.
14957 (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change author: %s'), authorName),
14958 onClick: onClick,
14959 children: authorName
14960 });
14961 }
14962
14963 /**
14964 * Renders the Post Author Panel component.
14965 *
14966 * @return {Component} The component to be rendered.
14967 */
14968 function panel_PostAuthor() {
14969 // Use internal state instead of a ref to make sure that the component
14970 // re-renders when the popover's anchor updates.
14971 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
14972 // Memoize popoverProps to avoid returning a new object every time.
14973 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
14974 // Anchor the popover to the middle of the entire row so that it doesn't
14975 // move around when the label changes.
14976 anchor: popoverAnchor,
14977 placement: 'left-start',
14978 offset: 36,
14979 shift: true
14980 }), [popoverAnchor]);
14981 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCheck, {
14982 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
14983 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
14984 ref: setPopoverAnchor,
14985 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
14986 popoverProps: popoverProps,
14987 contentClassName: "editor-post-author__panel-dialog",
14988 focusOnMount: true,
14989 renderToggle: ({
14990 isOpen,
14991 onToggle
14992 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorToggle, {
14993 isOpen: isOpen,
14994 onClick: onToggle
14995 }),
14996 renderContent: ({
14997 onClose
14998 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14999 className: "editor-post-author",
15000 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
15001 title: (0,external_wp_i18n_namespaceObject.__)('Author'),
15002 onClose: onClose
15003 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_author, {
15004 onClose: onClose
15005 })]
15006 })
15007 })
15008 })
15009 });
15010 }
15011 /* harmony default export */ const panel = (panel_PostAuthor);
15012
15013 ;// ./packages/editor/build-module/components/post-comments/index.js
15014 /**
15015 * WordPress dependencies
15016 */
15017
15018
15019
15020
15021 /**
15022 * Internal dependencies
15023 */
15024
15025
15026 const COMMENT_OPTIONS = [{
15027 label: (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"'),
15028 value: 'open',
15029 description: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
15030 }, {
15031 label: (0,external_wp_i18n_namespaceObject.__)('Closed'),
15032 value: 'closed',
15033 description: [(0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.'), (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')].join(' ')
15034 }];
15035 function PostComments() {
15036 const commentStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
15037 var _select$getEditedPost;
15038 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('comment_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
15039 }, []);
15040 const {
15041 editPost
15042 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15043 const handleStatus = newCommentStatus => editPost({
15044 comment_status: newCommentStatus
15045 });
15046 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
15047 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
15048 spacing: 4,
15049 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
15050 className: "editor-change-status__options",
15051 hideLabelFromVision: true,
15052 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
15053 options: COMMENT_OPTIONS,
15054 onChange: handleStatus,
15055 selected: commentStatus
15056 })
15057 })
15058 });
15059 }
15060
15061 /**
15062 * A form for managing comment status.
15063 *
15064 * @return {JSX.Element} The rendered PostComments component.
15065 */
15066 /* harmony default export */ const post_comments = (PostComments);
15067
15068 ;// ./packages/editor/build-module/components/post-pingbacks/index.js
15069 /**
15070 * WordPress dependencies
15071 */
15072
15073
15074
15075
15076 /**
15077 * Internal dependencies
15078 */
15079
15080
15081 function PostPingbacks() {
15082 const pingStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
15083 var _select$getEditedPost;
15084 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('ping_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
15085 }, []);
15086 const {
15087 editPost
15088 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15089 const onTogglePingback = () => editPost({
15090 ping_status: pingStatus === 'open' ? 'closed' : 'open'
15091 });
15092 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
15093 __nextHasNoMarginBottom: true,
15094 label: (0,external_wp_i18n_namespaceObject.__)('Enable pingbacks & trackbacks'),
15095 checked: pingStatus === 'open',
15096 onChange: onTogglePingback,
15097 help: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
15098 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/trackbacks-and-pingbacks/'),
15099 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about pingbacks & trackbacks')
15100 })
15101 });
15102 }
15103
15104 /**
15105 * Renders a control for enabling or disabling pingbacks and trackbacks
15106 * in a WordPress post.
15107 *
15108 * @module PostPingbacks
15109 */
15110 /* harmony default export */ const post_pingbacks = (PostPingbacks);
15111
15112 ;// ./packages/editor/build-module/components/post-discussion/panel.js
15113 /**
15114 * WordPress dependencies
15115 */
15116
15117
15118
15119
15120
15121
15122
15123 /**
15124 * Internal dependencies
15125 */
15126
15127
15128
15129
15130
15131
15132 const panel_PANEL_NAME = 'discussion-panel';
15133 function ModalContents({
15134 onClose
15135 }) {
15136 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15137 className: "editor-post-discussion",
15138 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
15139 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
15140 onClose: onClose
15141 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
15142 spacing: 4,
15143 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
15144 supportKeys: "comments",
15145 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_comments, {})
15146 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
15147 supportKeys: "trackbacks",
15148 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pingbacks, {})
15149 })]
15150 })]
15151 });
15152 }
15153 function PostDiscussionToggle({
15154 isOpen,
15155 onClick
15156 }) {
15157 const {
15158 commentStatus,
15159 pingStatus,
15160 commentsSupported,
15161 trackbacksSupported
15162 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15163 var _getEditedPostAttribu, _getEditedPostAttribu2;
15164 const {
15165 getEditedPostAttribute
15166 } = select(store_store);
15167 const {
15168 getPostType
15169 } = select(external_wp_coreData_namespaceObject.store);
15170 const postType = getPostType(getEditedPostAttribute('type'));
15171 return {
15172 commentStatus: (_getEditedPostAttribu = getEditedPostAttribute('comment_status')) !== null && _getEditedPostAttribu !== void 0 ? _getEditedPostAttribu : 'open',
15173 pingStatus: (_getEditedPostAttribu2 = getEditedPostAttribute('ping_status')) !== null && _getEditedPostAttribu2 !== void 0 ? _getEditedPostAttribu2 : 'open',
15174 commentsSupported: !!postType.supports.comments,
15175 trackbacksSupported: !!postType.supports.trackbacks
15176 };
15177 }, []);
15178 let label;
15179 if (commentStatus === 'open') {
15180 if (pingStatus === 'open') {
15181 label = (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"');
15182 } else {
15183 label = trackbacksSupported ? (0,external_wp_i18n_namespaceObject.__)('Comments only') : (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"');
15184 }
15185 } else if (pingStatus === 'open') {
15186 label = commentsSupported ? (0,external_wp_i18n_namespaceObject.__)('Pings only') : (0,external_wp_i18n_namespaceObject.__)('Pings enabled');
15187 } else {
15188 label = (0,external_wp_i18n_namespaceObject.__)('Closed');
15189 }
15190 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15191 size: "compact",
15192 className: "editor-post-discussion__panel-toggle",
15193 variant: "tertiary",
15194 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion options'),
15195 "aria-expanded": isOpen,
15196 onClick: onClick,
15197 children: label
15198 });
15199 }
15200
15201 /**
15202 * This component allows to update comment and pingback
15203 * settings for the current post. Internally there are
15204 * checks whether the current post has support for the
15205 * above and if the `discussion-panel` panel is enabled.
15206 *
15207 * @return {JSX.Element|null} The rendered PostDiscussionPanel component.
15208 */
15209 function PostDiscussionPanel() {
15210 const {
15211 isEnabled
15212 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15213 const {
15214 isEditorPanelEnabled
15215 } = select(store_store);
15216 return {
15217 isEnabled: isEditorPanelEnabled(panel_PANEL_NAME)
15218 };
15219 }, []);
15220
15221 // Use internal state instead of a ref to make sure that the component
15222 // re-renders when the popover's anchor updates.
15223 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
15224 // Memoize popoverProps to avoid returning a new object every time.
15225 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
15226 // Anchor the popover to the middle of the entire row so that it doesn't
15227 // move around when the label changes.
15228 anchor: popoverAnchor,
15229 placement: 'left-start',
15230 offset: 36,
15231 shift: true
15232 }), [popoverAnchor]);
15233 if (!isEnabled) {
15234 return null;
15235 }
15236 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
15237 supportKeys: ['comments', 'trackbacks'],
15238 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
15239 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
15240 ref: setPopoverAnchor,
15241 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
15242 popoverProps: popoverProps,
15243 className: "editor-post-discussion__panel-dropdown",
15244 contentClassName: "editor-post-discussion__panel-dialog",
15245 focusOnMount: true,
15246 renderToggle: ({
15247 isOpen,
15248 onToggle
15249 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostDiscussionToggle, {
15250 isOpen: isOpen,
15251 onClick: onToggle
15252 }),
15253 renderContent: ({
15254 onClose
15255 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ModalContents, {
15256 onClose: onClose
15257 })
15258 })
15259 })
15260 });
15261 }
15262
15263 ;// ./packages/editor/build-module/components/post-excerpt/index.js
15264 /**
15265 * WordPress dependencies
15266 */
15267
15268
15269
15270
15271
15272
15273 /**
15274 * Internal dependencies
15275 */
15276
15277
15278 /**
15279 * Renders an editable textarea for the post excerpt.
15280 * Templates, template parts and patterns use the `excerpt` field as a description semantically.
15281 * Additionally templates and template parts override the `excerpt` field as `description` in
15282 * REST API. So this component handles proper labeling and updating the edited entity.
15283 *
15284 * @param {Object} props - Component props.
15285 * @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.
15286 * @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.
15287 */
15288
15289 function PostExcerpt({
15290 hideLabelFromVision = false,
15291 updateOnBlur = false
15292 }) {
15293 const {
15294 excerpt,
15295 shouldUseDescriptionLabel,
15296 usedAttribute
15297 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15298 const {
15299 getCurrentPostType,
15300 getEditedPostAttribute
15301 } = select(store_store);
15302 const postType = getCurrentPostType();
15303 // This special case is unfortunate, but the REST API of wp_template and wp_template_part
15304 // support the excerpt field throught the "description" field rather than "excerpt".
15305 const _usedAttribute = ['wp_template', 'wp_template_part'].includes(postType) ? 'description' : 'excerpt';
15306 return {
15307 excerpt: getEditedPostAttribute(_usedAttribute),
15308 // There are special cases where we want to label the excerpt as a description.
15309 shouldUseDescriptionLabel: ['wp_template', 'wp_template_part', 'wp_block'].includes(postType),
15310 usedAttribute: _usedAttribute
15311 };
15312 }, []);
15313 const {
15314 editPost
15315 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15316 const [localExcerpt, setLocalExcerpt] = (0,external_wp_element_namespaceObject.useState)((0,external_wp_htmlEntities_namespaceObject.decodeEntities)(excerpt));
15317 const updatePost = value => {
15318 editPost({
15319 [usedAttribute]: value
15320 });
15321 };
15322 const label = shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Write a description (optional)') : (0,external_wp_i18n_namespaceObject.__)('Write an excerpt (optional)');
15323 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
15324 className: "editor-post-excerpt",
15325 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
15326 __nextHasNoMarginBottom: true,
15327 label: label,
15328 hideLabelFromVision: hideLabelFromVision,
15329 className: "editor-post-excerpt__textarea",
15330 onChange: updateOnBlur ? setLocalExcerpt : updatePost,
15331 onBlur: updateOnBlur ? () => updatePost(localExcerpt) : undefined,
15332 value: updateOnBlur ? localExcerpt : excerpt,
15333 help: !shouldUseDescriptionLabel ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
15334 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'),
15335 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about manual excerpts')
15336 }) : (0,external_wp_i18n_namespaceObject.__)('Write a description')
15337 })
15338 });
15339 }
15340
15341 ;// ./packages/editor/build-module/components/post-excerpt/check.js
15342 /**
15343 * Internal dependencies
15344 */
15345
15346
15347 /**
15348 * Component for checking if the post type supports the excerpt field.
15349 *
15350 * @param {Object} props Props.
15351 * @param {Element} props.children Children to be rendered.
15352 *
15353 * @return {Component} The component to be rendered.
15354 */
15355
15356 function PostExcerptCheck({
15357 children
15358 }) {
15359 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
15360 supportKeys: "excerpt",
15361 children: children
15362 });
15363 }
15364 /* harmony default export */ const post_excerpt_check = (PostExcerptCheck);
15365
15366 ;// ./packages/editor/build-module/components/post-excerpt/plugin.js
15367 /**
15368 * Defines as extensibility slot for the Excerpt panel.
15369 */
15370
15371 /**
15372 * WordPress dependencies
15373 */
15374
15375
15376 const {
15377 Fill: plugin_Fill,
15378 Slot: plugin_Slot
15379 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostExcerpt');
15380
15381 /**
15382 * Renders a post excerpt panel in the post sidebar.
15383 *
15384 * @param {Object} props Component properties.
15385 * @param {string} [props.className] An optional class name added to the row.
15386 * @param {Element} props.children Children to be rendered.
15387 *
15388 * @example
15389 * ```js
15390 * // Using ES5 syntax
15391 * var __ = wp.i18n.__;
15392 * var PluginPostExcerpt = wp.editPost.__experimentalPluginPostExcerpt;
15393 *
15394 * function MyPluginPostExcerpt() {
15395 * return React.createElement(
15396 * PluginPostExcerpt,
15397 * {
15398 * className: 'my-plugin-post-excerpt',
15399 * },
15400 * __( 'Post excerpt custom content' )
15401 * )
15402 * }
15403 * ```
15404 *
15405 * @example
15406 * ```jsx
15407 * // Using ESNext syntax
15408 * import { __ } from '@wordpress/i18n';
15409 * import { __experimentalPluginPostExcerpt as PluginPostExcerpt } from '@wordpress/edit-post';
15410 *
15411 * const MyPluginPostExcerpt = () => (
15412 * <PluginPostExcerpt className="my-plugin-post-excerpt">
15413 * { __( 'Post excerpt custom content' ) }
15414 * </PluginPostExcerpt>
15415 * );
15416 * ```
15417 *
15418 * @return {Component} The component to be rendered.
15419 */
15420 const PluginPostExcerpt = ({
15421 children,
15422 className
15423 }) => {
15424 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_Fill, {
15425 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
15426 className: className,
15427 children: children
15428 })
15429 });
15430 };
15431 PluginPostExcerpt.Slot = plugin_Slot;
15432 /* harmony default export */ const post_excerpt_plugin = (PluginPostExcerpt);
15433
15434 ;// ./packages/editor/build-module/components/post-excerpt/panel.js
15435 /**
15436 * WordPress dependencies
15437 */
15438
15439
15440
15441
15442
15443
15444
15445
15446 /**
15447 * Internal dependencies
15448 */
15449
15450
15451
15452
15453
15454
15455 /**
15456 * Module Constants
15457 */
15458
15459 const post_excerpt_panel_PANEL_NAME = 'post-excerpt';
15460 function ExcerptPanel() {
15461 const {
15462 isOpened,
15463 isEnabled,
15464 postType
15465 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15466 const {
15467 isEditorPanelOpened,
15468 isEditorPanelEnabled,
15469 getCurrentPostType
15470 } = select(store_store);
15471 return {
15472 isOpened: isEditorPanelOpened(post_excerpt_panel_PANEL_NAME),
15473 isEnabled: isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME),
15474 postType: getCurrentPostType()
15475 };
15476 }, []);
15477 const {
15478 toggleEditorPanelOpened
15479 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15480 const toggleExcerptPanel = () => toggleEditorPanelOpened(post_excerpt_panel_PANEL_NAME);
15481 if (!isEnabled) {
15482 return null;
15483 }
15484
15485 // There are special cases where we want to label the excerpt as a description.
15486 const shouldUseDescriptionLabel = ['wp_template', 'wp_template_part', 'wp_block'].includes(postType);
15487 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
15488 title: shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
15489 opened: isOpened,
15490 onToggle: toggleExcerptPanel,
15491 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
15492 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
15493 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {}), fills]
15494 })
15495 })
15496 });
15497 }
15498
15499 /**
15500 * Is rendered if the post type supports excerpts and allows editing the excerpt.
15501 *
15502 * @return {JSX.Element} The rendered PostExcerptPanel component.
15503 */
15504 function PostExcerptPanel() {
15505 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
15506 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExcerptPanel, {})
15507 });
15508 }
15509 function PrivatePostExcerptPanel() {
15510 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
15511 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateExcerpt, {})
15512 });
15513 }
15514 function PrivateExcerpt() {
15515 const {
15516 shouldRender,
15517 excerpt,
15518 shouldBeUsedAsDescription,
15519 allowEditing
15520 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15521 const {
15522 getCurrentPostType,
15523 getCurrentPostId,
15524 getEditedPostAttribute,
15525 isEditorPanelEnabled
15526 } = select(store_store);
15527 const postType = getCurrentPostType();
15528 const isTemplateOrTemplatePart = ['wp_template', 'wp_template_part'].includes(postType);
15529 const isPattern = postType === 'wp_block';
15530 // These post types use the `excerpt` field as a description semantically, so we need to
15531 // handle proper labeling and some flows where we should always render them as text.
15532 const _shouldBeUsedAsDescription = isTemplateOrTemplatePart || isPattern;
15533 const _usedAttribute = isTemplateOrTemplatePart ? 'description' : 'excerpt';
15534 // We need to fetch the entity in this case to check if we'll allow editing.
15535 const template = isTemplateOrTemplatePart && select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType, getCurrentPostId());
15536 // For post types that use excerpt as description, we do not abide
15537 // by the `isEnabled` panel flag in order to render them as text.
15538 const _shouldRender = isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME) || _shouldBeUsedAsDescription;
15539 return {
15540 excerpt: getEditedPostAttribute(_usedAttribute),
15541 shouldRender: _shouldRender,
15542 shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
15543 // If we should render, allow editing for all post types that are not used as description.
15544 // For the rest allow editing only for user generated entities.
15545 allowEditing: _shouldRender && (!_shouldBeUsedAsDescription || isPattern || template && template.source === constants_TEMPLATE_ORIGINS.custom && !template.has_theme_file && template.is_custom)
15546 };
15547 }, []);
15548 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
15549 const label = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt');
15550 // Memoize popoverProps to avoid returning a new object every time.
15551 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
15552 // Anchor the popover to the middle of the entire row so that it doesn't
15553 // move around when the label changes.
15554 anchor: popoverAnchor,
15555 'aria-label': label,
15556 headerTitle: label,
15557 placement: 'left-start',
15558 offset: 36,
15559 shift: true
15560 }), [popoverAnchor, label]);
15561 if (!shouldRender) {
15562 return false;
15563 }
15564 const excerptText = !!excerpt && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
15565 align: "left",
15566 numberOfLines: 4,
15567 truncate: allowEditing,
15568 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(excerpt)
15569 });
15570 if (!allowEditing) {
15571 return excerptText;
15572 }
15573 const excerptPlaceholder = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Add a description…') : (0,external_wp_i18n_namespaceObject.__)('Add an excerpt…');
15574 const triggerEditLabel = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Edit description') : (0,external_wp_i18n_namespaceObject.__)('Edit excerpt');
15575 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
15576 children: [excerptText, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
15577 className: "editor-post-excerpt__dropdown",
15578 contentClassName: "editor-post-excerpt__dropdown__content",
15579 popoverProps: popoverProps,
15580 focusOnMount: true,
15581 ref: setPopoverAnchor,
15582 renderToggle: ({
15583 onToggle
15584 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15585 __next40pxDefaultSize: true,
15586 onClick: onToggle,
15587 variant: "link",
15588 children: excerptText ? triggerEditLabel : excerptPlaceholder
15589 }),
15590 renderContent: ({
15591 onClose
15592 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
15593 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
15594 title: label,
15595 onClose: onClose
15596 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
15597 spacing: 4,
15598 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
15599 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
15600 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {
15601 hideLabelFromVision: true,
15602 updateOnBlur: true
15603 }), fills]
15604 })
15605 })
15606 })]
15607 })
15608 })]
15609 });
15610 }
15611
15612 ;// ./packages/editor/build-module/components/theme-support-check/index.js
15613 /**
15614 * WordPress dependencies
15615 */
15616
15617
15618
15619 /**
15620 * Internal dependencies
15621 */
15622
15623
15624 /**
15625 * Checks if the current theme supports specific features and renders the children if supported.
15626 *
15627 * @param {Object} props The component props.
15628 * @param {Element} props.children The children to render if the theme supports the specified features.
15629 * @param {string|string[]} props.supportKeys The key(s) of the theme support(s) to check.
15630 *
15631 * @return {JSX.Element|null} The rendered children if the theme supports the specified features, otherwise null.
15632 */
15633 function ThemeSupportCheck({
15634 children,
15635 supportKeys
15636 }) {
15637 const {
15638 postType,
15639 themeSupports
15640 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15641 return {
15642 postType: select(store_store).getEditedPostAttribute('type'),
15643 themeSupports: select(external_wp_coreData_namespaceObject.store).getThemeSupports()
15644 };
15645 }, []);
15646 const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => {
15647 var _themeSupports$key;
15648 const supported = (_themeSupports$key = themeSupports?.[key]) !== null && _themeSupports$key !== void 0 ? _themeSupports$key : false;
15649 // 'post-thumbnails' can be boolean or an array of post types.
15650 // In the latter case, we need to verify `postType` exists
15651 // within `supported`. If `postType` isn't passed, then the check
15652 // should fail.
15653 if ('post-thumbnails' === key && Array.isArray(supported)) {
15654 return supported.includes(postType);
15655 }
15656 return supported;
15657 });
15658 if (!isSupported) {
15659 return null;
15660 }
15661 return children;
15662 }
15663
15664 ;// ./packages/editor/build-module/components/post-featured-image/check.js
15665 /**
15666 * Internal dependencies
15667 */
15668
15669
15670
15671 /**
15672 * Wrapper component that renders its children only if the post type supports a featured image
15673 * and the theme supports post thumbnails.
15674 *
15675 * @param {Object} props Props.
15676 * @param {Element} props.children Children to be rendered.
15677 *
15678 * @return {Component} The component to be rendered.
15679 */
15680
15681 function PostFeaturedImageCheck({
15682 children
15683 }) {
15684 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ThemeSupportCheck, {
15685 supportKeys: "post-thumbnails",
15686 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
15687 supportKeys: "thumbnail",
15688 children: children
15689 })
15690 });
15691 }
15692 /* harmony default export */ const post_featured_image_check = (PostFeaturedImageCheck);
15693
15694 ;// ./packages/editor/build-module/components/post-featured-image/index.js
15695 /**
15696 * WordPress dependencies
15697 */
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708 /**
15709 * Internal dependencies
15710 */
15711
15712
15713
15714 const ALLOWED_MEDIA_TYPES = ['image'];
15715
15716 // Used when labels from post type were not yet loaded or when they are not present.
15717 const DEFAULT_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Featured image');
15718 const DEFAULT_SET_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Add a featured image');
15719 const instructions = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15720 children: (0,external_wp_i18n_namespaceObject.__)('To edit the featured image, you need permission to upload media.')
15721 });
15722 function getMediaDetails(media, postId) {
15723 var _media$media_details$, _media$media_details$2;
15724 if (!media) {
15725 return {};
15726 }
15727 const defaultSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'large', media.id, postId);
15728 if (defaultSize in ((_media$media_details$ = media?.media_details?.sizes) !== null && _media$media_details$ !== void 0 ? _media$media_details$ : {})) {
15729 return {
15730 mediaWidth: media.media_details.sizes[defaultSize].width,
15731 mediaHeight: media.media_details.sizes[defaultSize].height,
15732 mediaSourceUrl: media.media_details.sizes[defaultSize].source_url
15733 };
15734 }
15735
15736 // Use fallbackSize when defaultSize is not available.
15737 const fallbackSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, postId);
15738 if (fallbackSize in ((_media$media_details$2 = media?.media_details?.sizes) !== null && _media$media_details$2 !== void 0 ? _media$media_details$2 : {})) {
15739 return {
15740 mediaWidth: media.media_details.sizes[fallbackSize].width,
15741 mediaHeight: media.media_details.sizes[fallbackSize].height,
15742 mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url
15743 };
15744 }
15745
15746 // Use full image size when fallbackSize and defaultSize are not available.
15747 return {
15748 mediaWidth: media.media_details.width,
15749 mediaHeight: media.media_details.height,
15750 mediaSourceUrl: media.source_url
15751 };
15752 }
15753 function PostFeaturedImage({
15754 currentPostId,
15755 featuredImageId,
15756 onUpdateImage,
15757 onRemoveImage,
15758 media,
15759 postType,
15760 noticeUI,
15761 noticeOperations
15762 }) {
15763 const toggleRef = (0,external_wp_element_namespaceObject.useRef)();
15764 const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
15765 const {
15766 getSettings
15767 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
15768 const {
15769 mediaSourceUrl
15770 } = getMediaDetails(media, currentPostId);
15771 function onDropFiles(filesList) {
15772 getSettings().mediaUpload({
15773 allowedTypes: ALLOWED_MEDIA_TYPES,
15774 filesList,
15775 onFileChange([image]) {
15776 if ((0,external_wp_blob_namespaceObject.isBlobURL)(image?.url)) {
15777 setIsLoading(true);
15778 return;
15779 }
15780 if (image) {
15781 onUpdateImage(image);
15782 }
15783 setIsLoading(false);
15784 },
15785 onError(message) {
15786 noticeOperations.removeAllNotices();
15787 noticeOperations.createErrorNotice(message);
15788 }
15789 });
15790 }
15791
15792 /**
15793 * Generates the featured image alt text for this editing context.
15794 *
15795 * @param {Object} imageMedia The image media object.
15796 * @param {string} imageMedia.alt_text The alternative text of the image.
15797 * @param {Object} imageMedia.media_details The media details of the image.
15798 * @param {Object} imageMedia.media_details.sizes The sizes of the image.
15799 * @param {Object} imageMedia.media_details.sizes.full The full size details of the image.
15800 * @param {string} imageMedia.media_details.sizes.full.file The file name of the full size image.
15801 * @param {string} imageMedia.slug The slug of the image.
15802 * @return {string} The featured image alt text.
15803 */
15804 function getImageDescription(imageMedia) {
15805 if (imageMedia.alt_text) {
15806 return (0,external_wp_i18n_namespaceObject.sprintf)(
15807 // Translators: %s: The selected image alt text.
15808 (0,external_wp_i18n_namespaceObject.__)('Current image: %s'), imageMedia.alt_text);
15809 }
15810 return (0,external_wp_i18n_namespaceObject.sprintf)(
15811 // Translators: %s: The selected image filename.
15812 (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);
15813 }
15814 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(post_featured_image_check, {
15815 children: [noticeUI, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15816 className: "editor-post-featured-image",
15817 children: [media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
15818 id: `editor-post-featured-image-${featuredImageId}-describedby`,
15819 className: "hidden",
15820 children: getImageDescription(media)
15821 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, {
15822 fallback: instructions,
15823 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUpload, {
15824 title: postType?.labels?.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
15825 onSelect: onUpdateImage,
15826 unstableFeaturedImageFlow: true,
15827 allowedTypes: ALLOWED_MEDIA_TYPES,
15828 modalClass: "editor-post-featured-image__media-modal",
15829 render: ({
15830 open
15831 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15832 className: "editor-post-featured-image__container",
15833 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
15834 __next40pxDefaultSize: true,
15835 ref: toggleRef,
15836 className: !featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview',
15837 onClick: open,
15838 "aria-label": !featuredImageId ? null : (0,external_wp_i18n_namespaceObject.__)('Edit or replace the featured image'),
15839 "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`,
15840 "aria-haspopup": "dialog",
15841 disabled: isLoading,
15842 accessibleWhenDisabled: true,
15843 children: [!!featuredImageId && media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
15844 className: "editor-post-featured-image__preview-image",
15845 src: mediaSourceUrl,
15846 alt: getImageDescription(media)
15847 }), isLoading && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}), !featuredImageId && !isLoading && (postType?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)]
15848 }), !!featuredImageId && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
15849 className: "editor-post-featured-image__actions",
15850 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15851 __next40pxDefaultSize: true,
15852 className: "editor-post-featured-image__action",
15853 onClick: open,
15854 "aria-haspopup": "dialog",
15855 children: (0,external_wp_i18n_namespaceObject.__)('Replace')
15856 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15857 __next40pxDefaultSize: true,
15858 className: "editor-post-featured-image__action",
15859 onClick: () => {
15860 onRemoveImage();
15861 toggleRef.current.focus();
15862 },
15863 children: (0,external_wp_i18n_namespaceObject.__)('Remove')
15864 })]
15865 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropZone, {
15866 onFilesDrop: onDropFiles
15867 })]
15868 }),
15869 value: featuredImageId
15870 })
15871 })]
15872 })]
15873 });
15874 }
15875 const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)(select => {
15876 const {
15877 getMedia,
15878 getPostType
15879 } = select(external_wp_coreData_namespaceObject.store);
15880 const {
15881 getCurrentPostId,
15882 getEditedPostAttribute
15883 } = select(store_store);
15884 const featuredImageId = getEditedPostAttribute('featured_media');
15885 return {
15886 media: featuredImageId ? getMedia(featuredImageId, {
15887 context: 'view'
15888 }) : null,
15889 currentPostId: getCurrentPostId(),
15890 postType: getPostType(getEditedPostAttribute('type')),
15891 featuredImageId
15892 };
15893 });
15894 const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
15895 noticeOperations
15896 }, {
15897 select
15898 }) => {
15899 const {
15900 editPost
15901 } = dispatch(store_store);
15902 return {
15903 onUpdateImage(image) {
15904 editPost({
15905 featured_media: image.id
15906 });
15907 },
15908 onDropImage(filesList) {
15909 select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload({
15910 allowedTypes: ['image'],
15911 filesList,
15912 onFileChange([image]) {
15913 editPost({
15914 featured_media: image.id
15915 });
15916 },
15917 onError(message) {
15918 noticeOperations.removeAllNotices();
15919 noticeOperations.createErrorNotice(message);
15920 }
15921 });
15922 },
15923 onRemoveImage() {
15924 editPost({
15925 featured_media: 0
15926 });
15927 }
15928 };
15929 });
15930
15931 /**
15932 * Renders the component for managing the featured image of a post.
15933 *
15934 * @param {Object} props Props.
15935 * @param {number} props.currentPostId ID of the current post.
15936 * @param {number} props.featuredImageId ID of the featured image.
15937 * @param {Function} props.onUpdateImage Function to call when the image is updated.
15938 * @param {Function} props.onRemoveImage Function to call when the image is removed.
15939 * @param {Object} props.media The media object representing the featured image.
15940 * @param {string} props.postType Post type.
15941 * @param {Element} props.noticeUI UI for displaying notices.
15942 * @param {Object} props.noticeOperations Operations for managing notices.
15943 *
15944 * @return {Element} Component to be rendered .
15945 */
15946 /* 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));
15947
15948 ;// ./packages/editor/build-module/components/post-featured-image/panel.js
15949 /**
15950 * WordPress dependencies
15951 */
15952
15953
15954
15955
15956
15957 /**
15958 * Internal dependencies
15959 */
15960
15961
15962
15963
15964 const post_featured_image_panel_PANEL_NAME = 'featured-image';
15965
15966 /**
15967 * Renders the panel for the post featured image.
15968 *
15969 * @param {Object} props Props.
15970 * @param {boolean} props.withPanelBody Whether to include the panel body. Default true.
15971 *
15972 * @return {Component|null} The component to be rendered.
15973 * Return Null if the editor panel is disabled for featured image.
15974 */
15975 function PostFeaturedImagePanel({
15976 withPanelBody = true
15977 }) {
15978 var _postType$labels$feat;
15979 const {
15980 postType,
15981 isEnabled,
15982 isOpened
15983 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15984 const {
15985 getEditedPostAttribute,
15986 isEditorPanelEnabled,
15987 isEditorPanelOpened
15988 } = select(store_store);
15989 const {
15990 getPostType
15991 } = select(external_wp_coreData_namespaceObject.store);
15992 return {
15993 postType: getPostType(getEditedPostAttribute('type')),
15994 isEnabled: isEditorPanelEnabled(post_featured_image_panel_PANEL_NAME),
15995 isOpened: isEditorPanelOpened(post_featured_image_panel_PANEL_NAME)
15996 };
15997 }, []);
15998 const {
15999 toggleEditorPanelOpened
16000 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16001 if (!isEnabled) {
16002 return null;
16003 }
16004 if (!withPanelBody) {
16005 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
16006 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
16007 });
16008 }
16009 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
16010 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16011 title: (_postType$labels$feat = postType?.labels?.featured_image) !== null && _postType$labels$feat !== void 0 ? _postType$labels$feat : (0,external_wp_i18n_namespaceObject.__)('Featured image'),
16012 opened: isOpened,
16013 onToggle: () => toggleEditorPanelOpened(post_featured_image_panel_PANEL_NAME),
16014 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
16015 })
16016 });
16017 }
16018
16019 ;// ./packages/editor/build-module/components/post-format/check.js
16020 /**
16021 * WordPress dependencies
16022 */
16023
16024
16025 /**
16026 * Internal dependencies
16027 */
16028
16029
16030
16031 function PostFormatCheck({
16032 children
16033 }) {
16034 const disablePostFormats = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().disablePostFormats, []);
16035 if (disablePostFormats) {
16036 return null;
16037 }
16038 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
16039 supportKeys: "post-formats",
16040 children: children
16041 });
16042 }
16043
16044 /**
16045 * Component check if there are any post formats.
16046 *
16047 * @param {Object} props The component props.
16048 * @param {Element} props.children The child elements to render.
16049 *
16050 * @return {Component|null} The rendered component or null if post formats are disabled.
16051 */
16052 /* harmony default export */ const post_format_check = (PostFormatCheck);
16053
16054 ;// ./packages/editor/build-module/components/post-format/index.js
16055 /**
16056 * WordPress dependencies
16057 */
16058
16059
16060
16061
16062
16063
16064 /**
16065 * Internal dependencies
16066 */
16067
16068
16069
16070 // All WP post formats, sorted alphabetically by translated name.
16071
16072 const POST_FORMATS = [{
16073 id: 'aside',
16074 caption: (0,external_wp_i18n_namespaceObject.__)('Aside')
16075 }, {
16076 id: 'audio',
16077 caption: (0,external_wp_i18n_namespaceObject.__)('Audio')
16078 }, {
16079 id: 'chat',
16080 caption: (0,external_wp_i18n_namespaceObject.__)('Chat')
16081 }, {
16082 id: 'gallery',
16083 caption: (0,external_wp_i18n_namespaceObject.__)('Gallery')
16084 }, {
16085 id: 'image',
16086 caption: (0,external_wp_i18n_namespaceObject.__)('Image')
16087 }, {
16088 id: 'link',
16089 caption: (0,external_wp_i18n_namespaceObject.__)('Link')
16090 }, {
16091 id: 'quote',
16092 caption: (0,external_wp_i18n_namespaceObject.__)('Quote')
16093 }, {
16094 id: 'standard',
16095 caption: (0,external_wp_i18n_namespaceObject.__)('Standard')
16096 }, {
16097 id: 'status',
16098 caption: (0,external_wp_i18n_namespaceObject.__)('Status')
16099 }, {
16100 id: 'video',
16101 caption: (0,external_wp_i18n_namespaceObject.__)('Video')
16102 }].sort((a, b) => {
16103 const normalizedA = a.caption.toUpperCase();
16104 const normalizedB = b.caption.toUpperCase();
16105 if (normalizedA < normalizedB) {
16106 return -1;
16107 }
16108 if (normalizedA > normalizedB) {
16109 return 1;
16110 }
16111 return 0;
16112 });
16113
16114 /**
16115 * `PostFormat` a component that allows changing the post format while also providing a suggestion for the current post.
16116 *
16117 * @example
16118 * ```jsx
16119 * <PostFormat />
16120 * ```
16121 *
16122 * @return {JSX.Element} The rendered PostFormat component.
16123 */
16124 function PostFormat() {
16125 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostFormat);
16126 const postFormatSelectorId = `post-format-selector-${instanceId}`;
16127 const {
16128 postFormat,
16129 suggestedFormat,
16130 supportedFormats
16131 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16132 const {
16133 getEditedPostAttribute,
16134 getSuggestedPostFormat
16135 } = select(store_store);
16136 const _postFormat = getEditedPostAttribute('format');
16137 const themeSupports = select(external_wp_coreData_namespaceObject.store).getThemeSupports();
16138 return {
16139 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard',
16140 suggestedFormat: getSuggestedPostFormat(),
16141 supportedFormats: themeSupports.formats
16142 };
16143 }, []);
16144 const formats = POST_FORMATS.filter(format => {
16145 // Ensure current format is always in the set.
16146 // The current format may not be a format supported by the theme.
16147 return supportedFormats?.includes(format.id) || postFormat === format.id;
16148 });
16149 const suggestion = formats.find(format => format.id === suggestedFormat);
16150 const {
16151 editPost
16152 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16153 const onUpdatePostFormat = format => editPost({
16154 format
16155 });
16156 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_check, {
16157 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16158 className: "editor-post-format",
16159 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
16160 className: "editor-post-format__options",
16161 label: (0,external_wp_i18n_namespaceObject.__)('Post Format'),
16162 selected: postFormat,
16163 onChange: format => onUpdatePostFormat(format),
16164 id: postFormatSelectorId,
16165 options: formats.map(format => ({
16166 label: format.caption,
16167 value: format.id
16168 })),
16169 hideLabelFromVision: true
16170 }), suggestion && suggestion.id !== postFormat && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16171 className: "editor-post-format__suggestion",
16172 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16173 __next40pxDefaultSize: true,
16174 variant: "link",
16175 onClick: () => onUpdatePostFormat(suggestion.id),
16176 children: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: post format */
16177 (0,external_wp_i18n_namespaceObject.__)('Apply suggested format: %s'), suggestion.caption)
16178 })
16179 })]
16180 })
16181 });
16182 }
16183
16184 ;// ./packages/editor/build-module/components/post-last-revision/check.js
16185 /**
16186 * WordPress dependencies
16187 */
16188
16189
16190 /**
16191 * Internal dependencies
16192 */
16193
16194
16195
16196 /**
16197 * Wrapper component that renders its children if the post has more than one revision.
16198 *
16199 * @param {Object} props Props.
16200 * @param {Element} props.children Children to be rendered.
16201 *
16202 * @return {Component|null} Rendered child components if post has more than one revision, otherwise null.
16203 */
16204
16205 function PostLastRevisionCheck({
16206 children
16207 }) {
16208 const {
16209 lastRevisionId,
16210 revisionsCount
16211 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16212 const {
16213 getCurrentPostLastRevisionId,
16214 getCurrentPostRevisionsCount
16215 } = select(store_store);
16216 return {
16217 lastRevisionId: getCurrentPostLastRevisionId(),
16218 revisionsCount: getCurrentPostRevisionsCount()
16219 };
16220 }, []);
16221 if (!lastRevisionId || revisionsCount < 2) {
16222 return null;
16223 }
16224 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
16225 supportKeys: "revisions",
16226 children: children
16227 });
16228 }
16229 /* harmony default export */ const post_last_revision_check = (PostLastRevisionCheck);
16230
16231 ;// ./packages/editor/build-module/components/post-last-revision/index.js
16232 /**
16233 * WordPress dependencies
16234 */
16235
16236
16237
16238
16239
16240
16241 /**
16242 * Internal dependencies
16243 */
16244
16245
16246
16247
16248 function usePostLastRevisionInfo() {
16249 return (0,external_wp_data_namespaceObject.useSelect)(select => {
16250 const {
16251 getCurrentPostLastRevisionId,
16252 getCurrentPostRevisionsCount
16253 } = select(store_store);
16254 return {
16255 lastRevisionId: getCurrentPostLastRevisionId(),
16256 revisionsCount: getCurrentPostRevisionsCount()
16257 };
16258 }, []);
16259 }
16260
16261 /**
16262 * Renders the component for displaying the last revision of a post.
16263 *
16264 * @return {Component} The component to be rendered.
16265 */
16266 function PostLastRevision() {
16267 const {
16268 lastRevisionId,
16269 revisionsCount
16270 } = usePostLastRevisionInfo();
16271 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
16272 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16273 __next40pxDefaultSize: true,
16274 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
16275 revision: lastRevisionId
16276 }),
16277 className: "editor-post-last-revision__title",
16278 icon: library_backup,
16279 iconPosition: "right",
16280 text: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: number of revisions. */
16281 (0,external_wp_i18n_namespaceObject.__)('Revisions (%s)'), revisionsCount)
16282 })
16283 });
16284 }
16285 function PrivatePostLastRevision() {
16286 const {
16287 lastRevisionId,
16288 revisionsCount
16289 } = usePostLastRevisionInfo();
16290 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
16291 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
16292 label: (0,external_wp_i18n_namespaceObject.__)('Revisions'),
16293 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16294 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
16295 revision: lastRevisionId
16296 }),
16297 className: "editor-private-post-last-revision__button",
16298 text: revisionsCount,
16299 variant: "tertiary",
16300 size: "compact"
16301 })
16302 })
16303 });
16304 }
16305 /* harmony default export */ const post_last_revision = (PostLastRevision);
16306
16307 ;// ./packages/editor/build-module/components/post-last-revision/panel.js
16308 /**
16309 * WordPress dependencies
16310 */
16311
16312
16313 /**
16314 * Internal dependencies
16315 */
16316
16317
16318
16319 /**
16320 * Renders the panel for displaying the last revision of a post.
16321 *
16322 * @return {Component} The component to be rendered.
16323 */
16324
16325 function PostLastRevisionPanel() {
16326 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
16327 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16328 className: "editor-post-last-revision__panel",
16329 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision, {})
16330 })
16331 });
16332 }
16333 /* harmony default export */ const post_last_revision_panel = (PostLastRevisionPanel);
16334
16335 ;// ./packages/editor/build-module/components/post-locked-modal/index.js
16336 /**
16337 * WordPress dependencies
16338 */
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348 /**
16349 * Internal dependencies
16350 */
16351
16352
16353 /**
16354 * A modal component that is displayed when a post is locked for editing by another user.
16355 * The modal provides information about the lock status and options to take over or exit the editor.
16356 *
16357 * @return {JSX.Element|null} The rendered PostLockedModal component.
16358 */
16359
16360 function PostLockedModal() {
16361 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostLockedModal);
16362 const hookName = 'core/editor/post-locked-modal-' + instanceId;
16363 const {
16364 autosave,
16365 updatePostLock
16366 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16367 const {
16368 isLocked,
16369 isTakeover,
16370 user,
16371 postId,
16372 postLockUtils,
16373 activePostLock,
16374 postType,
16375 previewLink
16376 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16377 const {
16378 isPostLocked,
16379 isPostLockTakeover,
16380 getPostLockUser,
16381 getCurrentPostId,
16382 getActivePostLock,
16383 getEditedPostAttribute,
16384 getEditedPostPreviewLink,
16385 getEditorSettings
16386 } = select(store_store);
16387 const {
16388 getPostType
16389 } = select(external_wp_coreData_namespaceObject.store);
16390 return {
16391 isLocked: isPostLocked(),
16392 isTakeover: isPostLockTakeover(),
16393 user: getPostLockUser(),
16394 postId: getCurrentPostId(),
16395 postLockUtils: getEditorSettings().postLockUtils,
16396 activePostLock: getActivePostLock(),
16397 postType: getPostType(getEditedPostAttribute('type')),
16398 previewLink: getEditedPostPreviewLink()
16399 };
16400 }, []);
16401 (0,external_wp_element_namespaceObject.useEffect)(() => {
16402 /**
16403 * Keep the lock refreshed.
16404 *
16405 * When the user does not send a heartbeat in a heartbeat-tick
16406 * the user is no longer editing and another user can start editing.
16407 *
16408 * @param {Object} data Data to send in the heartbeat request.
16409 */
16410 function sendPostLock(data) {
16411 if (isLocked) {
16412 return;
16413 }
16414 data['wp-refresh-post-lock'] = {
16415 lock: activePostLock,
16416 post_id: postId
16417 };
16418 }
16419
16420 /**
16421 * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.
16422 *
16423 * @param {Object} data Data received in the heartbeat request
16424 */
16425 function receivePostLock(data) {
16426 if (!data['wp-refresh-post-lock']) {
16427 return;
16428 }
16429 const received = data['wp-refresh-post-lock'];
16430 if (received.lock_error) {
16431 // Auto save and display the takeover modal.
16432 autosave();
16433 updatePostLock({
16434 isLocked: true,
16435 isTakeover: true,
16436 user: {
16437 name: received.lock_error.name,
16438 avatar: received.lock_error.avatar_src_2x
16439 }
16440 });
16441 } else if (received.new_lock) {
16442 updatePostLock({
16443 isLocked: false,
16444 activePostLock: received.new_lock
16445 });
16446 }
16447 }
16448
16449 /**
16450 * Unlock the post before the window is exited.
16451 */
16452 function releasePostLock() {
16453 if (isLocked || !activePostLock) {
16454 return;
16455 }
16456 const data = new window.FormData();
16457 data.append('action', 'wp-remove-post-lock');
16458 data.append('_wpnonce', postLockUtils.unlockNonce);
16459 data.append('post_ID', postId);
16460 data.append('active_post_lock', activePostLock);
16461 if (window.navigator.sendBeacon) {
16462 window.navigator.sendBeacon(postLockUtils.ajaxUrl, data);
16463 } else {
16464 const xhr = new window.XMLHttpRequest();
16465 xhr.open('POST', postLockUtils.ajaxUrl, false);
16466 xhr.send(data);
16467 }
16468 }
16469
16470 // Details on these events on the Heartbeat API docs
16471 // https://developer.wordpress.org/plugins/javascript/heartbeat-api/
16472 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.send', hookName, sendPostLock);
16473 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.tick', hookName, receivePostLock);
16474 window.addEventListener('beforeunload', releasePostLock);
16475 return () => {
16476 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.send', hookName);
16477 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.tick', hookName);
16478 window.removeEventListener('beforeunload', releasePostLock);
16479 };
16480 }, []);
16481 if (!isLocked) {
16482 return null;
16483 }
16484 const userDisplayName = user.name;
16485 const userAvatar = user.avatar;
16486 const unlockUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
16487 'get-post-lock': '1',
16488 lockKey: true,
16489 post: postId,
16490 action: 'edit',
16491 _wpnonce: postLockUtils.nonce
16492 });
16493 const allPostsUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
16494 post_type: postType?.slug
16495 });
16496 const allPostsLabel = (0,external_wp_i18n_namespaceObject.__)('Exit editor');
16497 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
16498 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'),
16499 focusOnMount: true,
16500 shouldCloseOnClickOutside: false,
16501 shouldCloseOnEsc: false,
16502 isDismissible: false
16503 // Do not remove this class, as this class is used by third party plugins.
16504 ,
16505 className: "editor-post-locked-modal",
16506 size: "medium",
16507 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
16508 alignment: "top",
16509 spacing: 6,
16510 children: [!!userAvatar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
16511 src: userAvatar,
16512 alt: (0,external_wp_i18n_namespaceObject.__)('Avatar'),
16513 className: "editor-post-locked-modal__avatar",
16514 width: 64,
16515 height: 64
16516 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16517 children: [!!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16518 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: user's display name */
16519 (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.'), {
16520 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
16521 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
16522 href: previewLink,
16523 children: (0,external_wp_i18n_namespaceObject.__)('preview')
16524 })
16525 })
16526 }), !isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16527 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16528 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: user's display name */
16529 (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.'), {
16530 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
16531 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
16532 href: previewLink,
16533 children: (0,external_wp_i18n_namespaceObject.__)('preview')
16534 })
16535 })
16536 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16537 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.')
16538 })]
16539 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
16540 className: "editor-post-locked-modal__buttons",
16541 justify: "flex-end",
16542 children: [!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16543 __next40pxDefaultSize: true,
16544 variant: "tertiary",
16545 href: unlockUrl,
16546 children: (0,external_wp_i18n_namespaceObject.__)('Take over')
16547 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16548 __next40pxDefaultSize: true,
16549 variant: "primary",
16550 href: allPostsUrl,
16551 children: allPostsLabel
16552 })]
16553 })]
16554 })]
16555 })
16556 });
16557 }
16558
16559 ;// ./packages/editor/build-module/components/post-pending-status/check.js
16560 /**
16561 * WordPress dependencies
16562 */
16563
16564
16565 /**
16566 * Internal dependencies
16567 */
16568
16569
16570 /**
16571 * This component checks the publishing status of the current post.
16572 * If the post is already published or the user doesn't have the
16573 * capability to publish, it returns null.
16574 *
16575 * @param {Object} props Component properties.
16576 * @param {Element} props.children Children to be rendered.
16577 *
16578 * @return {JSX.Element|null} The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
16579 */
16580 function PostPendingStatusCheck({
16581 children
16582 }) {
16583 const {
16584 hasPublishAction,
16585 isPublished
16586 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16587 var _getCurrentPost$_link;
16588 const {
16589 isCurrentPostPublished,
16590 getCurrentPost
16591 } = select(store_store);
16592 return {
16593 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16594 isPublished: isCurrentPostPublished()
16595 };
16596 }, []);
16597 if (isPublished || !hasPublishAction) {
16598 return null;
16599 }
16600 return children;
16601 }
16602 /* harmony default export */ const post_pending_status_check = (PostPendingStatusCheck);
16603
16604 ;// ./packages/editor/build-module/components/post-pending-status/index.js
16605 /**
16606 * WordPress dependencies
16607 */
16608
16609
16610
16611
16612 /**
16613 * Internal dependencies
16614 */
16615
16616
16617
16618 /**
16619 * A component for displaying and toggling the pending status of a post.
16620 *
16621 * @return {JSX.Element} The rendered component.
16622 */
16623
16624 function PostPendingStatus() {
16625 const status = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('status'), []);
16626 const {
16627 editPost
16628 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16629 const togglePendingStatus = () => {
16630 const updatedStatus = status === 'pending' ? 'draft' : 'pending';
16631 editPost({
16632 status: updatedStatus
16633 });
16634 };
16635 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pending_status_check, {
16636 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
16637 __nextHasNoMarginBottom: true,
16638 label: (0,external_wp_i18n_namespaceObject.__)('Pending review'),
16639 checked: status === 'pending',
16640 onChange: togglePendingStatus
16641 })
16642 });
16643 }
16644 /* harmony default export */ const post_pending_status = (PostPendingStatus);
16645
16646 ;// ./packages/editor/build-module/components/post-preview-button/index.js
16647 /**
16648 * WordPress dependencies
16649 */
16650
16651
16652
16653
16654
16655
16656
16657 /**
16658 * Internal dependencies
16659 */
16660
16661
16662 function writeInterstitialMessage(targetDocument) {
16663 let markup = (0,external_wp_element_namespaceObject.renderToString)(/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16664 className: "editor-post-preview-button__interstitial-message",
16665 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
16666 xmlns: "http://www.w3.org/2000/svg",
16667 viewBox: "0 0 96 96",
16668 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
16669 className: "outer",
16670 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36",
16671 fill: "none"
16672 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
16673 className: "inner",
16674 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",
16675 fill: "none"
16676 })]
16677 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16678 children: (0,external_wp_i18n_namespaceObject.__)('Generating preview…')
16679 })]
16680 }));
16681 markup += `
16682 <style>
16683 body {
16684 margin: 0;
16685 }
16686 .editor-post-preview-button__interstitial-message {
16687 display: flex;
16688 flex-direction: column;
16689 align-items: center;
16690 justify-content: center;
16691 height: 100vh;
16692 width: 100vw;
16693 }
16694 @-webkit-keyframes paint {
16695 0% {
16696 stroke-dashoffset: 0;
16697 }
16698 }
16699 @-moz-keyframes paint {
16700 0% {
16701 stroke-dashoffset: 0;
16702 }
16703 }
16704 @-o-keyframes paint {
16705 0% {
16706 stroke-dashoffset: 0;
16707 }
16708 }
16709 @keyframes paint {
16710 0% {
16711 stroke-dashoffset: 0;
16712 }
16713 }
16714 .editor-post-preview-button__interstitial-message svg {
16715 width: 192px;
16716 height: 192px;
16717 stroke: #555d66;
16718 stroke-width: 0.75;
16719 }
16720 .editor-post-preview-button__interstitial-message svg .outer,
16721 .editor-post-preview-button__interstitial-message svg .inner {
16722 stroke-dasharray: 280;
16723 stroke-dashoffset: 280;
16724 -webkit-animation: paint 1.5s ease infinite alternate;
16725 -moz-animation: paint 1.5s ease infinite alternate;
16726 -o-animation: paint 1.5s ease infinite alternate;
16727 animation: paint 1.5s ease infinite alternate;
16728 }
16729 p {
16730 text-align: center;
16731 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
16732 }
16733 </style>
16734 `;
16735
16736 /**
16737 * Filters the interstitial message shown when generating previews.
16738 *
16739 * @param {string} markup The preview interstitial markup.
16740 */
16741 markup = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostPreview.interstitialMarkup', markup);
16742 targetDocument.write(markup);
16743 targetDocument.title = (0,external_wp_i18n_namespaceObject.__)('Generating preview…');
16744 targetDocument.close();
16745 }
16746
16747 /**
16748 * Renders a button that opens a new window or tab for the preview,
16749 * writes the interstitial message to this window, and then navigates
16750 * to the actual preview link. The button is not rendered if the post
16751 * is not viewable and disabled if the post is not saveable.
16752 *
16753 * @param {Object} props The component props.
16754 * @param {string} props.className The class name for the button.
16755 * @param {string} props.textContent The text content for the button.
16756 * @param {boolean} props.forceIsAutosaveable Whether to force autosave.
16757 * @param {string} props.role The role attribute for the button.
16758 * @param {Function} props.onPreview The callback function for preview event.
16759 *
16760 * @return {JSX.Element|null} The rendered button component.
16761 */
16762 function PostPreviewButton({
16763 className,
16764 textContent,
16765 forceIsAutosaveable,
16766 role,
16767 onPreview
16768 }) {
16769 const {
16770 postId,
16771 currentPostLink,
16772 previewLink,
16773 isSaveable,
16774 isViewable
16775 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16776 var _postType$viewable;
16777 const editor = select(store_store);
16778 const core = select(external_wp_coreData_namespaceObject.store);
16779 const postType = core.getPostType(editor.getCurrentPostType('type'));
16780 return {
16781 postId: editor.getCurrentPostId(),
16782 currentPostLink: editor.getCurrentPostAttribute('link'),
16783 previewLink: editor.getEditedPostPreviewLink(),
16784 isSaveable: editor.isEditedPostSaveable(),
16785 isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false
16786 };
16787 }, []);
16788 const {
16789 __unstableSaveForPreview
16790 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16791 if (!isViewable) {
16792 return null;
16793 }
16794 const targetId = `wp-preview-${postId}`;
16795 const openPreviewWindow = async event => {
16796 // Our Preview button has its 'href' and 'target' set correctly for a11y
16797 // purposes. Unfortunately, though, we can't rely on the default 'click'
16798 // handler since sometimes it incorrectly opens a new tab instead of reusing
16799 // the existing one.
16800 // https://github.com/WordPress/gutenberg/pull/8330
16801 event.preventDefault();
16802
16803 // Open up a Preview tab if needed. This is where we'll show the preview.
16804 const previewWindow = window.open('', targetId);
16805
16806 // Focus the Preview tab. This might not do anything, depending on the browser's
16807 // and user's preferences.
16808 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
16809 previewWindow.focus();
16810 writeInterstitialMessage(previewWindow.document);
16811 const link = await __unstableSaveForPreview({
16812 forceIsAutosaveable
16813 });
16814 previewWindow.location = link;
16815 onPreview?.();
16816 };
16817
16818 // Link to the `?preview=true` URL if we have it, since this lets us see
16819 // changes that were autosaved since the post was last published. Otherwise,
16820 // just link to the post's URL.
16821 const href = previewLink || currentPostLink;
16822 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16823 variant: !className ? 'tertiary' : undefined,
16824 className: className || 'editor-post-preview',
16825 href: href,
16826 target: targetId,
16827 accessibleWhenDisabled: true,
16828 disabled: !isSaveable,
16829 onClick: openPreviewWindow,
16830 role: role,
16831 size: "compact",
16832 children: textContent || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16833 children: [(0,external_wp_i18n_namespaceObject._x)('Preview', 'imperative verb'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
16834 as: "span",
16835 children: /* translators: accessibility text */
16836 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
16837 })]
16838 })
16839 });
16840 }
16841
16842 ;// ./packages/editor/build-module/components/post-publish-button/label.js
16843 /**
16844 * WordPress dependencies
16845 */
16846
16847
16848
16849
16850 /**
16851 * Internal dependencies
16852 */
16853
16854
16855 /**
16856 * Renders the label for the publish button.
16857 *
16858 * @return {string} The label for the publish button.
16859 */
16860 function PublishButtonLabel() {
16861 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
16862 const {
16863 isPublished,
16864 isBeingScheduled,
16865 isSaving,
16866 isPublishing,
16867 hasPublishAction,
16868 isAutosaving,
16869 hasNonPostEntityChanges,
16870 postStatusHasChanged,
16871 postStatus
16872 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16873 var _getCurrentPost$_link;
16874 const {
16875 isCurrentPostPublished,
16876 isEditedPostBeingScheduled,
16877 isSavingPost,
16878 isPublishingPost,
16879 getCurrentPost,
16880 getCurrentPostType,
16881 isAutosavingPost,
16882 getPostEdits,
16883 getEditedPostAttribute
16884 } = select(store_store);
16885 return {
16886 isPublished: isCurrentPostPublished(),
16887 isBeingScheduled: isEditedPostBeingScheduled(),
16888 isSaving: isSavingPost(),
16889 isPublishing: isPublishingPost(),
16890 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16891 postType: getCurrentPostType(),
16892 isAutosaving: isAutosavingPost(),
16893 hasNonPostEntityChanges: select(store_store).hasNonPostEntityChanges(),
16894 postStatusHasChanged: !!getPostEdits()?.status,
16895 postStatus: getEditedPostAttribute('status')
16896 };
16897 }, []);
16898 if (isPublishing) {
16899 /* translators: button label text should, if possible, be under 16 characters. */
16900 return (0,external_wp_i18n_namespaceObject.__)('Publishing…');
16901 } else if ((isPublished || isBeingScheduled) && isSaving && !isAutosaving) {
16902 /* translators: button label text should, if possible, be under 16 characters. */
16903 return (0,external_wp_i18n_namespaceObject.__)('Saving…');
16904 }
16905 if (!hasPublishAction) {
16906 // TODO: this is because "Submit for review" string is too long in some languages.
16907 // @see https://github.com/WordPress/gutenberg/issues/10475
16908 return isSmallerThanMediumViewport ? (0,external_wp_i18n_namespaceObject.__)('Publish') : (0,external_wp_i18n_namespaceObject.__)('Submit for Review');
16909 }
16910 if (hasNonPostEntityChanges || isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || !postStatusHasChanged && postStatus === 'future') {
16911 return (0,external_wp_i18n_namespaceObject.__)('Save');
16912 }
16913 if (isBeingScheduled) {
16914 return (0,external_wp_i18n_namespaceObject.__)('Schedule');
16915 }
16916 return (0,external_wp_i18n_namespaceObject.__)('Publish');
16917 }
16918
16919 ;// ./packages/editor/build-module/components/post-publish-button/index.js
16920 /**
16921 * WordPress dependencies
16922 */
16923
16924
16925
16926
16927
16928 /**
16929 * Internal dependencies
16930 */
16931
16932
16933
16934 const post_publish_button_noop = () => {};
16935 class PostPublishButton extends external_wp_element_namespaceObject.Component {
16936 constructor(props) {
16937 super(props);
16938 this.createOnClick = this.createOnClick.bind(this);
16939 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this);
16940 this.state = {
16941 entitiesSavedStatesCallback: false
16942 };
16943 }
16944 createOnClick(callback) {
16945 return (...args) => {
16946 const {
16947 hasNonPostEntityChanges,
16948 setEntitiesSavedStatesCallback
16949 } = this.props;
16950 // If a post with non-post entities is published, but the user
16951 // elects to not save changes to the non-post entities, those
16952 // entities will still be dirty when the Publish button is clicked.
16953 // We also need to check that the `setEntitiesSavedStatesCallback`
16954 // prop was passed. See https://github.com/WordPress/gutenberg/pull/37383
16955 if (hasNonPostEntityChanges && setEntitiesSavedStatesCallback) {
16956 // The modal for multiple entity saving will open,
16957 // hold the callback for saving/publishing the post
16958 // so that we can call it if the post entity is checked.
16959 this.setState({
16960 entitiesSavedStatesCallback: () => callback(...args)
16961 });
16962
16963 // Open the save panel by setting its callback.
16964 // To set a function on the useState hook, we must set it
16965 // with another function (() => myFunction). Passing the
16966 // function on its own will cause an error when called.
16967 setEntitiesSavedStatesCallback(() => this.closeEntitiesSavedStates);
16968 return post_publish_button_noop;
16969 }
16970 return callback(...args);
16971 };
16972 }
16973 closeEntitiesSavedStates(savedEntities) {
16974 const {
16975 postType,
16976 postId
16977 } = this.props;
16978 const {
16979 entitiesSavedStatesCallback
16980 } = this.state;
16981 this.setState({
16982 entitiesSavedStatesCallback: false
16983 }, () => {
16984 if (savedEntities && savedEntities.some(elt => elt.kind === 'postType' && elt.name === postType && elt.key === postId)) {
16985 // The post entity was checked, call the held callback from `createOnClick`.
16986 entitiesSavedStatesCallback();
16987 }
16988 });
16989 }
16990 render() {
16991 const {
16992 forceIsDirty,
16993 hasPublishAction,
16994 isBeingScheduled,
16995 isOpen,
16996 isPostSavingLocked,
16997 isPublishable,
16998 isPublished,
16999 isSaveable,
17000 isSaving,
17001 isAutoSaving,
17002 isToggle,
17003 savePostStatus,
17004 onSubmit = post_publish_button_noop,
17005 onToggle,
17006 visibility,
17007 hasNonPostEntityChanges,
17008 isSavingNonPostEntityChanges,
17009 postStatus,
17010 postStatusHasChanged
17011 } = this.props;
17012 const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
17013 const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
17014
17015 // If the new status has not changed explicitely, we derive it from
17016 // other factors, like having a publish action, etc.. We need to preserve
17017 // this because it affects when to show the pre and post publish panels.
17018 // If it has changed though explicitely, we need to respect that.
17019 let publishStatus = 'publish';
17020 if (postStatusHasChanged) {
17021 publishStatus = postStatus;
17022 } else if (!hasPublishAction) {
17023 publishStatus = 'pending';
17024 } else if (visibility === 'private') {
17025 publishStatus = 'private';
17026 } else if (isBeingScheduled) {
17027 publishStatus = 'future';
17028 }
17029 const onClickButton = () => {
17030 if (isButtonDisabled) {
17031 return;
17032 }
17033 onSubmit();
17034 savePostStatus(publishStatus);
17035 };
17036
17037 // Callback to open the publish panel.
17038 const onClickToggle = () => {
17039 if (isToggleDisabled) {
17040 return;
17041 }
17042 onToggle();
17043 };
17044 const buttonProps = {
17045 'aria-disabled': isButtonDisabled,
17046 className: 'editor-post-publish-button',
17047 isBusy: !isAutoSaving && isSaving,
17048 variant: 'primary',
17049 onClick: this.createOnClick(onClickButton)
17050 };
17051 const toggleProps = {
17052 'aria-disabled': isToggleDisabled,
17053 'aria-expanded': isOpen,
17054 className: 'editor-post-publish-panel__toggle',
17055 isBusy: isSaving && isPublished,
17056 variant: 'primary',
17057 size: 'compact',
17058 onClick: this.createOnClick(onClickToggle)
17059 };
17060 const componentProps = isToggle ? toggleProps : buttonProps;
17061 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17062 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17063 ...componentProps,
17064 className: `${componentProps.className} editor-post-publish-button__button`,
17065 size: "compact",
17066 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PublishButtonLabel, {})
17067 })
17068 });
17069 }
17070 }
17071
17072 /**
17073 * Renders the publish button.
17074 */
17075 /* harmony default export */ const post_publish_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
17076 var _getCurrentPost$_link;
17077 const {
17078 isSavingPost,
17079 isAutosavingPost,
17080 isEditedPostBeingScheduled,
17081 getEditedPostVisibility,
17082 isCurrentPostPublished,
17083 isEditedPostSaveable,
17084 isEditedPostPublishable,
17085 isPostSavingLocked,
17086 getCurrentPost,
17087 getCurrentPostType,
17088 getCurrentPostId,
17089 hasNonPostEntityChanges,
17090 isSavingNonPostEntityChanges,
17091 getEditedPostAttribute,
17092 getPostEdits
17093 } = select(store_store);
17094 return {
17095 isSaving: isSavingPost(),
17096 isAutoSaving: isAutosavingPost(),
17097 isBeingScheduled: isEditedPostBeingScheduled(),
17098 visibility: getEditedPostVisibility(),
17099 isSaveable: isEditedPostSaveable(),
17100 isPostSavingLocked: isPostSavingLocked(),
17101 isPublishable: isEditedPostPublishable(),
17102 isPublished: isCurrentPostPublished(),
17103 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
17104 postType: getCurrentPostType(),
17105 postId: getCurrentPostId(),
17106 postStatus: getEditedPostAttribute('status'),
17107 postStatusHasChanged: getPostEdits()?.status,
17108 hasNonPostEntityChanges: hasNonPostEntityChanges(),
17109 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges()
17110 };
17111 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
17112 const {
17113 editPost,
17114 savePost
17115 } = dispatch(store_store);
17116 return {
17117 savePostStatus: status => {
17118 editPost({
17119 status
17120 }, {
17121 undoIgnore: true
17122 });
17123 savePost();
17124 }
17125 };
17126 })])(PostPublishButton));
17127
17128 ;// ./packages/icons/build-module/library/wordpress.js
17129 /**
17130 * WordPress dependencies
17131 */
17132
17133
17134 const wordpress = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
17135 xmlns: "http://www.w3.org/2000/svg",
17136 viewBox: "-2 -2 24 24",
17137 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
17138 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"
17139 })
17140 });
17141 /* harmony default export */ const library_wordpress = (wordpress);
17142
17143 ;// ./packages/editor/build-module/components/post-visibility/utils.js
17144 /**
17145 * WordPress dependencies
17146 */
17147
17148 const visibilityOptions = {
17149 public: {
17150 label: (0,external_wp_i18n_namespaceObject.__)('Public'),
17151 info: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
17152 },
17153 private: {
17154 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
17155 info: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
17156 },
17157 password: {
17158 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
17159 info: (0,external_wp_i18n_namespaceObject.__)('Only those with the password can view this post.')
17160 }
17161 };
17162
17163 ;// ./packages/editor/build-module/components/post-visibility/index.js
17164 /**
17165 * WordPress dependencies
17166 */
17167
17168
17169
17170
17171
17172
17173
17174 /**
17175 * Internal dependencies
17176 */
17177
17178
17179
17180 /**
17181 * Allows users to set the visibility of a post.
17182 *
17183 * @param {Object} props The component props.
17184 * @param {Function} props.onClose Function to call when the popover is closed.
17185 * @return {JSX.Element} The rendered component.
17186 */
17187
17188 function PostVisibility({
17189 onClose
17190 }) {
17191 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostVisibility);
17192 const {
17193 status,
17194 visibility,
17195 password
17196 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
17197 status: select(store_store).getEditedPostAttribute('status'),
17198 visibility: select(store_store).getEditedPostVisibility(),
17199 password: select(store_store).getEditedPostAttribute('password')
17200 }));
17201 const {
17202 editPost,
17203 savePost
17204 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17205 const [hasPassword, setHasPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
17206 const [showPrivateConfirmDialog, setShowPrivateConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
17207 const setPublic = () => {
17208 editPost({
17209 status: visibility === 'private' ? 'draft' : status,
17210 password: ''
17211 });
17212 setHasPassword(false);
17213 };
17214 const setPrivate = () => {
17215 setShowPrivateConfirmDialog(true);
17216 };
17217 const confirmPrivate = () => {
17218 editPost({
17219 status: 'private',
17220 password: ''
17221 });
17222 setHasPassword(false);
17223 setShowPrivateConfirmDialog(false);
17224 savePost();
17225 };
17226 const handleDialogCancel = () => {
17227 setShowPrivateConfirmDialog(false);
17228 };
17229 const setPasswordProtected = () => {
17230 editPost({
17231 status: visibility === 'private' ? 'draft' : status,
17232 password: password || ''
17233 });
17234 setHasPassword(true);
17235 };
17236 const updatePassword = event => {
17237 editPost({
17238 password: event.target.value
17239 });
17240 };
17241 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
17242 className: "editor-post-visibility",
17243 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
17244 title: (0,external_wp_i18n_namespaceObject.__)('Visibility'),
17245 help: (0,external_wp_i18n_namespaceObject.__)('Control how this post is viewed.'),
17246 onClose: onClose
17247 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
17248 className: "editor-post-visibility__fieldset",
17249 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
17250 as: "legend",
17251 children: (0,external_wp_i18n_namespaceObject.__)('Visibility')
17252 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
17253 instanceId: instanceId,
17254 value: "public",
17255 label: visibilityOptions.public.label,
17256 info: visibilityOptions.public.info,
17257 checked: visibility === 'public' && !hasPassword,
17258 onChange: setPublic
17259 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
17260 instanceId: instanceId,
17261 value: "private",
17262 label: visibilityOptions.private.label,
17263 info: visibilityOptions.private.info,
17264 checked: visibility === 'private',
17265 onChange: setPrivate
17266 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
17267 instanceId: instanceId,
17268 value: "password",
17269 label: visibilityOptions.password.label,
17270 info: visibilityOptions.password.info,
17271 checked: hasPassword,
17272 onChange: setPasswordProtected
17273 }), hasPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
17274 className: "editor-post-visibility__password",
17275 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
17276 as: "label",
17277 htmlFor: `editor-post-visibility__password-input-${instanceId}`,
17278 children: (0,external_wp_i18n_namespaceObject.__)('Create password')
17279 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
17280 className: "editor-post-visibility__password-input",
17281 id: `editor-post-visibility__password-input-${instanceId}`,
17282 type: "text",
17283 onChange: updatePassword,
17284 value: password,
17285 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password')
17286 })]
17287 })]
17288 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
17289 isOpen: showPrivateConfirmDialog,
17290 onConfirm: confirmPrivate,
17291 onCancel: handleDialogCancel,
17292 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Publish'),
17293 size: "medium",
17294 children: (0,external_wp_i18n_namespaceObject.__)('Would you like to privately publish this post now?')
17295 })]
17296 });
17297 }
17298 function PostVisibilityChoice({
17299 instanceId,
17300 value,
17301 label,
17302 info,
17303 ...props
17304 }) {
17305 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
17306 className: "editor-post-visibility__choice",
17307 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
17308 type: "radio",
17309 name: `editor-post-visibility__setting-${instanceId}`,
17310 value: value,
17311 id: `editor-post-${value}-${instanceId}`,
17312 "aria-describedby": `editor-post-${value}-${instanceId}-description`,
17313 className: "editor-post-visibility__radio",
17314 ...props
17315 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("label", {
17316 htmlFor: `editor-post-${value}-${instanceId}`,
17317 className: "editor-post-visibility__label",
17318 children: label
17319 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
17320 id: `editor-post-${value}-${instanceId}-description`,
17321 className: "editor-post-visibility__info",
17322 children: info
17323 })]
17324 });
17325 }
17326
17327 ;// ./packages/editor/build-module/components/post-visibility/label.js
17328 /**
17329 * WordPress dependencies
17330 */
17331
17332
17333 /**
17334 * Internal dependencies
17335 */
17336
17337
17338
17339 /**
17340 * Returns the label for the current post visibility setting.
17341 *
17342 * @return {string} Post visibility label.
17343 */
17344 function PostVisibilityLabel() {
17345 return usePostVisibilityLabel();
17346 }
17347
17348 /**
17349 * Get the label for the current post visibility setting.
17350 *
17351 * @return {string} Post visibility label.
17352 */
17353 function usePostVisibilityLabel() {
17354 const visibility = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostVisibility());
17355 return visibilityOptions[visibility]?.label;
17356 }
17357
17358 ;// ./node_modules/date-fns/toDate.mjs
17359 /**
17360 * @name toDate
17361 * @category Common Helpers
17362 * @summary Convert the given argument to an instance of Date.
17363 *
17364 * @description
17365 * Convert the given argument to an instance of Date.
17366 *
17367 * If the argument is an instance of Date, the function returns its clone.
17368 *
17369 * If the argument is a number, it is treated as a timestamp.
17370 *
17371 * If the argument is none of the above, the function returns Invalid Date.
17372 *
17373 * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
17374 *
17375 * @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).
17376 *
17377 * @param argument - The value to convert
17378 *
17379 * @returns The parsed date in the local time zone
17380 *
17381 * @example
17382 * // Clone the date:
17383 * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
17384 * //=> Tue Feb 11 2014 11:30:30
17385 *
17386 * @example
17387 * // Convert the timestamp to date:
17388 * const result = toDate(1392098430000)
17389 * //=> Tue Feb 11 2014 11:30:30
17390 */
17391 function toDate(argument) {
17392 const argStr = Object.prototype.toString.call(argument);
17393
17394 // Clone the date
17395 if (
17396 argument instanceof Date ||
17397 (typeof argument === "object" && argStr === "[object Date]")
17398 ) {
17399 // Prevent the date to lose the milliseconds when passed to new Date() in IE10
17400 return new argument.constructor(+argument);
17401 } else if (
17402 typeof argument === "number" ||
17403 argStr === "[object Number]" ||
17404 typeof argument === "string" ||
17405 argStr === "[object String]"
17406 ) {
17407 // TODO: Can we get rid of as?
17408 return new Date(argument);
17409 } else {
17410 // TODO: Can we get rid of as?
17411 return new Date(NaN);
17412 }
17413 }
17414
17415 // Fallback for modularized imports:
17416 /* harmony default export */ const date_fns_toDate = ((/* unused pure expression or super */ null && (toDate)));
17417
17418 ;// ./node_modules/date-fns/startOfMonth.mjs
17419
17420
17421 /**
17422 * @name startOfMonth
17423 * @category Month Helpers
17424 * @summary Return the start of a month for the given date.
17425 *
17426 * @description
17427 * Return the start of a month for the given date.
17428 * The result will be in the local timezone.
17429 *
17430 * @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).
17431 *
17432 * @param date - The original date
17433 *
17434 * @returns The start of a month
17435 *
17436 * @example
17437 * // The start of a month for 2 September 2014 11:55:00:
17438 * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
17439 * //=> Mon Sep 01 2014 00:00:00
17440 */
17441 function startOfMonth(date) {
17442 const _date = toDate(date);
17443 _date.setDate(1);
17444 _date.setHours(0, 0, 0, 0);
17445 return _date;
17446 }
17447
17448 // Fallback for modularized imports:
17449 /* harmony default export */ const date_fns_startOfMonth = ((/* unused pure expression or super */ null && (startOfMonth)));
17450
17451 ;// ./node_modules/date-fns/endOfMonth.mjs
17452
17453
17454 /**
17455 * @name endOfMonth
17456 * @category Month Helpers
17457 * @summary Return the end of a month for the given date.
17458 *
17459 * @description
17460 * Return the end of a month for the given date.
17461 * The result will be in the local timezone.
17462 *
17463 * @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).
17464 *
17465 * @param date - The original date
17466 *
17467 * @returns The end of a month
17468 *
17469 * @example
17470 * // The end of a month for 2 September 2014 11:55:00:
17471 * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
17472 * //=> Tue Sep 30 2014 23:59:59.999
17473 */
17474 function endOfMonth(date) {
17475 const _date = toDate(date);
17476 const month = _date.getMonth();
17477 _date.setFullYear(_date.getFullYear(), month + 1, 0);
17478 _date.setHours(23, 59, 59, 999);
17479 return _date;
17480 }
17481
17482 // Fallback for modularized imports:
17483 /* harmony default export */ const date_fns_endOfMonth = ((/* unused pure expression or super */ null && (endOfMonth)));
17484
17485 ;// ./node_modules/date-fns/constants.mjs
17486 /**
17487 * @module constants
17488 * @summary Useful constants
17489 * @description
17490 * Collection of useful date constants.
17491 *
17492 * The constants could be imported from `date-fns/constants`:
17493 *
17494 * ```ts
17495 * import { maxTime, minTime } from "./constants/date-fns/constants";
17496 *
17497 * function isAllowedTime(time) {
17498 * return time <= maxTime && time >= minTime;
17499 * }
17500 * ```
17501 */
17502
17503 /**
17504 * @constant
17505 * @name daysInWeek
17506 * @summary Days in 1 week.
17507 */
17508 const daysInWeek = 7;
17509
17510 /**
17511 * @constant
17512 * @name daysInYear
17513 * @summary Days in 1 year.
17514 *
17515 * @description
17516 * How many days in a year.
17517 *
17518 * One years equals 365.2425 days according to the formula:
17519 *
17520 * > Leap year occures every 4 years, except for years that are divisable by 100 and not divisable by 400.
17521 * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days
17522 */
17523 const daysInYear = 365.2425;
17524
17525 /**
17526 * @constant
17527 * @name maxTime
17528 * @summary Maximum allowed time.
17529 *
17530 * @example
17531 * import { maxTime } from "./constants/date-fns/constants";
17532 *
17533 * const isValid = 8640000000000001 <= maxTime;
17534 * //=> false
17535 *
17536 * new Date(8640000000000001);
17537 * //=> Invalid Date
17538 */
17539 const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000;
17540
17541 /**
17542 * @constant
17543 * @name minTime
17544 * @summary Minimum allowed time.
17545 *
17546 * @example
17547 * import { minTime } from "./constants/date-fns/constants";
17548 *
17549 * const isValid = -8640000000000001 >= minTime;
17550 * //=> false
17551 *
17552 * new Date(-8640000000000001)
17553 * //=> Invalid Date
17554 */
17555 const minTime = -maxTime;
17556
17557 /**
17558 * @constant
17559 * @name millisecondsInWeek
17560 * @summary Milliseconds in 1 week.
17561 */
17562 const millisecondsInWeek = 604800000;
17563
17564 /**
17565 * @constant
17566 * @name millisecondsInDay
17567 * @summary Milliseconds in 1 day.
17568 */
17569 const millisecondsInDay = 86400000;
17570
17571 /**
17572 * @constant
17573 * @name millisecondsInMinute
17574 * @summary Milliseconds in 1 minute
17575 */
17576 const millisecondsInMinute = 60000;
17577
17578 /**
17579 * @constant
17580 * @name millisecondsInHour
17581 * @summary Milliseconds in 1 hour
17582 */
17583 const millisecondsInHour = 3600000;
17584
17585 /**
17586 * @constant
17587 * @name millisecondsInSecond
17588 * @summary Milliseconds in 1 second
17589 */
17590 const millisecondsInSecond = 1000;
17591
17592 /**
17593 * @constant
17594 * @name minutesInYear
17595 * @summary Minutes in 1 year.
17596 */
17597 const minutesInYear = 525600;
17598
17599 /**
17600 * @constant
17601 * @name minutesInMonth
17602 * @summary Minutes in 1 month.
17603 */
17604 const minutesInMonth = 43200;
17605
17606 /**
17607 * @constant
17608 * @name minutesInDay
17609 * @summary Minutes in 1 day.
17610 */
17611 const minutesInDay = 1440;
17612
17613 /**
17614 * @constant
17615 * @name minutesInHour
17616 * @summary Minutes in 1 hour.
17617 */
17618 const minutesInHour = 60;
17619
17620 /**
17621 * @constant
17622 * @name monthsInQuarter
17623 * @summary Months in 1 quarter.
17624 */
17625 const monthsInQuarter = 3;
17626
17627 /**
17628 * @constant
17629 * @name monthsInYear
17630 * @summary Months in 1 year.
17631 */
17632 const monthsInYear = 12;
17633
17634 /**
17635 * @constant
17636 * @name quartersInYear
17637 * @summary Quarters in 1 year
17638 */
17639 const quartersInYear = 4;
17640
17641 /**
17642 * @constant
17643 * @name secondsInHour
17644 * @summary Seconds in 1 hour.
17645 */
17646 const secondsInHour = 3600;
17647
17648 /**
17649 * @constant
17650 * @name secondsInMinute
17651 * @summary Seconds in 1 minute.
17652 */
17653 const secondsInMinute = 60;
17654
17655 /**
17656 * @constant
17657 * @name secondsInDay
17658 * @summary Seconds in 1 day.
17659 */
17660 const secondsInDay = secondsInHour * 24;
17661
17662 /**
17663 * @constant
17664 * @name secondsInWeek
17665 * @summary Seconds in 1 week.
17666 */
17667 const secondsInWeek = secondsInDay * 7;
17668
17669 /**
17670 * @constant
17671 * @name secondsInYear
17672 * @summary Seconds in 1 year.
17673 */
17674 const secondsInYear = secondsInDay * daysInYear;
17675
17676 /**
17677 * @constant
17678 * @name secondsInMonth
17679 * @summary Seconds in 1 month
17680 */
17681 const secondsInMonth = secondsInYear / 12;
17682
17683 /**
17684 * @constant
17685 * @name secondsInQuarter
17686 * @summary Seconds in 1 quarter.
17687 */
17688 const secondsInQuarter = secondsInMonth * 3;
17689
17690 ;// ./node_modules/date-fns/parseISO.mjs
17691
17692
17693 /**
17694 * The {@link parseISO} function options.
17695 */
17696
17697 /**
17698 * @name parseISO
17699 * @category Common Helpers
17700 * @summary Parse ISO string
17701 *
17702 * @description
17703 * Parse the given string in ISO 8601 format and return an instance of Date.
17704 *
17705 * Function accepts complete ISO 8601 formats as well as partial implementations.
17706 * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
17707 *
17708 * If the argument isn't a string, the function cannot parse the string or
17709 * the values are invalid, it returns Invalid Date.
17710 *
17711 * @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).
17712 *
17713 * @param argument - The value to convert
17714 * @param options - An object with options
17715 *
17716 * @returns The parsed date in the local time zone
17717 *
17718 * @example
17719 * // Convert string '2014-02-11T11:30:30' to date:
17720 * const result = parseISO('2014-02-11T11:30:30')
17721 * //=> Tue Feb 11 2014 11:30:30
17722 *
17723 * @example
17724 * // Convert string '+02014101' to date,
17725 * // if the additional number of digits in the extended year format is 1:
17726 * const result = parseISO('+02014101', { additionalDigits: 1 })
17727 * //=> Fri Apr 11 2014 00:00:00
17728 */
17729 function parseISO(argument, options) {
17730 const additionalDigits = options?.additionalDigits ?? 2;
17731 const dateStrings = splitDateString(argument);
17732
17733 let date;
17734 if (dateStrings.date) {
17735 const parseYearResult = parseYear(dateStrings.date, additionalDigits);
17736 date = parseDate(parseYearResult.restDateString, parseYearResult.year);
17737 }
17738
17739 if (!date || isNaN(date.getTime())) {
17740 return new Date(NaN);
17741 }
17742
17743 const timestamp = date.getTime();
17744 let time = 0;
17745 let offset;
17746
17747 if (dateStrings.time) {
17748 time = parseTime(dateStrings.time);
17749 if (isNaN(time)) {
17750 return new Date(NaN);
17751 }
17752 }
17753
17754 if (dateStrings.timezone) {
17755 offset = parseTimezone(dateStrings.timezone);
17756 if (isNaN(offset)) {
17757 return new Date(NaN);
17758 }
17759 } else {
17760 const dirtyDate = new Date(timestamp + time);
17761 // JS parsed string assuming it's in UTC timezone
17762 // but we need it to be parsed in our timezone
17763 // so we use utc values to build date in our timezone.
17764 // Year values from 0 to 99 map to the years 1900 to 1999
17765 // so set year explicitly with setFullYear.
17766 const result = new Date(0);
17767 result.setFullYear(
17768 dirtyDate.getUTCFullYear(),
17769 dirtyDate.getUTCMonth(),
17770 dirtyDate.getUTCDate(),
17771 );
17772 result.setHours(
17773 dirtyDate.getUTCHours(),
17774 dirtyDate.getUTCMinutes(),
17775 dirtyDate.getUTCSeconds(),
17776 dirtyDate.getUTCMilliseconds(),
17777 );
17778 return result;
17779 }
17780
17781 return new Date(timestamp + time + offset);
17782 }
17783
17784 const patterns = {
17785 dateTimeDelimiter: /[T ]/,
17786 timeZoneDelimiter: /[Z ]/i,
17787 timezone: /([Z+-].*)$/,
17788 };
17789
17790 const dateRegex =
17791 /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
17792 const timeRegex =
17793 /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
17794 const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
17795
17796 function splitDateString(dateString) {
17797 const dateStrings = {};
17798 const array = dateString.split(patterns.dateTimeDelimiter);
17799 let timeString;
17800
17801 // The regex match should only return at maximum two array elements.
17802 // [date], [time], or [date, time].
17803 if (array.length > 2) {
17804 return dateStrings;
17805 }
17806
17807 if (/:/.test(array[0])) {
17808 timeString = array[0];
17809 } else {
17810 dateStrings.date = array[0];
17811 timeString = array[1];
17812 if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
17813 dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
17814 timeString = dateString.substr(
17815 dateStrings.date.length,
17816 dateString.length,
17817 );
17818 }
17819 }
17820
17821 if (timeString) {
17822 const token = patterns.timezone.exec(timeString);
17823 if (token) {
17824 dateStrings.time = timeString.replace(token[1], "");
17825 dateStrings.timezone = token[1];
17826 } else {
17827 dateStrings.time = timeString;
17828 }
17829 }
17830
17831 return dateStrings;
17832 }
17833
17834 function parseYear(dateString, additionalDigits) {
17835 const regex = new RegExp(
17836 "^(?:(\\d{4}|[+-]\\d{" +
17837 (4 + additionalDigits) +
17838 "})|(\\d{2}|[+-]\\d{" +
17839 (2 + additionalDigits) +
17840 "})$)",
17841 );
17842
17843 const captures = dateString.match(regex);
17844 // Invalid ISO-formatted year
17845 if (!captures) return { year: NaN, restDateString: "" };
17846
17847 const year = captures[1] ? parseInt(captures[1]) : null;
17848 const century = captures[2] ? parseInt(captures[2]) : null;
17849
17850 // either year or century is null, not both
17851 return {
17852 year: century === null ? year : century * 100,
17853 restDateString: dateString.slice((captures[1] || captures[2]).length),
17854 };
17855 }
17856
17857 function parseDate(dateString, year) {
17858 // Invalid ISO-formatted year
17859 if (year === null) return new Date(NaN);
17860
17861 const captures = dateString.match(dateRegex);
17862 // Invalid ISO-formatted string
17863 if (!captures) return new Date(NaN);
17864
17865 const isWeekDate = !!captures[4];
17866 const dayOfYear = parseDateUnit(captures[1]);
17867 const month = parseDateUnit(captures[2]) - 1;
17868 const day = parseDateUnit(captures[3]);
17869 const week = parseDateUnit(captures[4]);
17870 const dayOfWeek = parseDateUnit(captures[5]) - 1;
17871
17872 if (isWeekDate) {
17873 if (!validateWeekDate(year, week, dayOfWeek)) {
17874 return new Date(NaN);
17875 }
17876 return dayOfISOWeekYear(year, week, dayOfWeek);
17877 } else {
17878 const date = new Date(0);
17879 if (
17880 !validateDate(year, month, day) ||
17881 !validateDayOfYearDate(year, dayOfYear)
17882 ) {
17883 return new Date(NaN);
17884 }
17885 date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
17886 return date;
17887 }
17888 }
17889
17890 function parseDateUnit(value) {
17891 return value ? parseInt(value) : 1;
17892 }
17893
17894 function parseTime(timeString) {
17895 const captures = timeString.match(timeRegex);
17896 if (!captures) return NaN; // Invalid ISO-formatted time
17897
17898 const hours = parseTimeUnit(captures[1]);
17899 const minutes = parseTimeUnit(captures[2]);
17900 const seconds = parseTimeUnit(captures[3]);
17901
17902 if (!validateTime(hours, minutes, seconds)) {
17903 return NaN;
17904 }
17905
17906 return (
17907 hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000
17908 );
17909 }
17910
17911 function parseTimeUnit(value) {
17912 return (value && parseFloat(value.replace(",", "."))) || 0;
17913 }
17914
17915 function parseTimezone(timezoneString) {
17916 if (timezoneString === "Z") return 0;
17917
17918 const captures = timezoneString.match(timezoneRegex);
17919 if (!captures) return 0;
17920
17921 const sign = captures[1] === "+" ? -1 : 1;
17922 const hours = parseInt(captures[2]);
17923 const minutes = (captures[3] && parseInt(captures[3])) || 0;
17924
17925 if (!validateTimezone(hours, minutes)) {
17926 return NaN;
17927 }
17928
17929 return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
17930 }
17931
17932 function dayOfISOWeekYear(isoWeekYear, week, day) {
17933 const date = new Date(0);
17934 date.setUTCFullYear(isoWeekYear, 0, 4);
17935 const fourthOfJanuaryDay = date.getUTCDay() || 7;
17936 const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
17937 date.setUTCDate(date.getUTCDate() + diff);
17938 return date;
17939 }
17940
17941 // Validation functions
17942
17943 // February is null to handle the leap year (using ||)
17944 const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
17945
17946 function isLeapYearIndex(year) {
17947 return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
17948 }
17949
17950 function validateDate(year, month, date) {
17951 return (
17952 month >= 0 &&
17953 month <= 11 &&
17954 date >= 1 &&
17955 date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28))
17956 );
17957 }
17958
17959 function validateDayOfYearDate(year, dayOfYear) {
17960 return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
17961 }
17962
17963 function validateWeekDate(_year, week, day) {
17964 return week >= 1 && week <= 53 && day >= 0 && day <= 6;
17965 }
17966
17967 function validateTime(hours, minutes, seconds) {
17968 if (hours === 24) {
17969 return minutes === 0 && seconds === 0;
17970 }
17971
17972 return (
17973 seconds >= 0 &&
17974 seconds < 60 &&
17975 minutes >= 0 &&
17976 minutes < 60 &&
17977 hours >= 0 &&
17978 hours < 25
17979 );
17980 }
17981
17982 function validateTimezone(_hours, minutes) {
17983 return minutes >= 0 && minutes <= 59;
17984 }
17985
17986 // Fallback for modularized imports:
17987 /* harmony default export */ const date_fns_parseISO = ((/* unused pure expression or super */ null && (parseISO)));
17988
17989 ;// ./packages/editor/build-module/components/post-schedule/index.js
17990 /**
17991 * External dependencies
17992 */
17993
17994
17995 /**
17996 * WordPress dependencies
17997 */
17998
17999
18000
18001
18002
18003
18004
18005 /**
18006 * Internal dependencies
18007 */
18008
18009
18010
18011 const {
18012 PrivatePublishDateTimePicker
18013 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
18014
18015 /**
18016 * Renders the PostSchedule component. It allows the user to schedule a post.
18017 *
18018 * @param {Object} props Props.
18019 * @param {Function} props.onClose Function to close the component.
18020 *
18021 * @return {Component} The component to be rendered.
18022 */
18023 function PostSchedule(props) {
18024 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
18025 ...props,
18026 showPopoverHeaderActions: true,
18027 isCompact: false
18028 });
18029 }
18030 function PrivatePostSchedule({
18031 onClose,
18032 showPopoverHeaderActions,
18033 isCompact
18034 }) {
18035 const {
18036 postDate,
18037 postType
18038 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
18039 postDate: select(store_store).getEditedPostAttribute('date'),
18040 postType: select(store_store).getCurrentPostType()
18041 }), []);
18042 const {
18043 editPost
18044 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18045 const onUpdateDate = date => editPost({
18046 date
18047 });
18048 const [previewedMonth, setPreviewedMonth] = (0,external_wp_element_namespaceObject.useState)(startOfMonth(new Date(postDate)));
18049
18050 // Pick up published and schduled site posts.
18051 const eventsByPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, {
18052 status: 'publish,future',
18053 after: startOfMonth(previewedMonth).toISOString(),
18054 before: endOfMonth(previewedMonth).toISOString(),
18055 exclude: [select(store_store).getCurrentPostId()],
18056 per_page: 100,
18057 _fields: 'id,date'
18058 }), [previewedMonth, postType]);
18059 const events = (0,external_wp_element_namespaceObject.useMemo)(() => (eventsByPostType || []).map(({
18060 date: eventDate
18061 }) => ({
18062 date: new Date(eventDate)
18063 })), [eventsByPostType]);
18064 const settings = (0,external_wp_date_namespaceObject.getSettings)();
18065
18066 // To know if the current timezone is a 12 hour time with look for "a" in the time format
18067 // We also make sure this a is not escaped by a "/"
18068 const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a.
18069 .replace(/\\\\/g, '') // Replace "//" with empty strings.
18070 .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
18071 );
18072 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePublishDateTimePicker, {
18073 currentDate: postDate,
18074 onChange: onUpdateDate,
18075 is12Hour: is12HourTime,
18076 dateOrder: /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
18077 (0,external_wp_i18n_namespaceObject._x)('dmy', 'date order'),
18078 events: events,
18079 onMonthPreviewed: date => setPreviewedMonth(parseISO(date)),
18080 onClose: onClose,
18081 isCompact: isCompact,
18082 showPopoverHeaderActions: showPopoverHeaderActions
18083 });
18084 }
18085
18086 ;// ./packages/editor/build-module/components/post-schedule/label.js
18087 /**
18088 * WordPress dependencies
18089 */
18090
18091
18092
18093
18094 /**
18095 * Internal dependencies
18096 */
18097
18098
18099 /**
18100 * Renders the PostScheduleLabel component.
18101 *
18102 * @param {Object} props Props.
18103 *
18104 * @return {Component} The component to be rendered.
18105 */
18106 function PostScheduleLabel(props) {
18107 return usePostScheduleLabel(props);
18108 }
18109
18110 /**
18111 * Custom hook to get the label for post schedule.
18112 *
18113 * @param {Object} options Options for the hook.
18114 * @param {boolean} options.full Whether to get the full label or not. Default is false.
18115 *
18116 * @return {string} The label for post schedule.
18117 */
18118 function usePostScheduleLabel({
18119 full = false
18120 } = {}) {
18121 const {
18122 date,
18123 isFloating
18124 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
18125 date: select(store_store).getEditedPostAttribute('date'),
18126 isFloating: select(store_store).isEditedPostDateFloating()
18127 }), []);
18128 return full ? getFullPostScheduleLabel(date) : getPostScheduleLabel(date, {
18129 isFloating
18130 });
18131 }
18132 function getFullPostScheduleLabel(dateAttribute) {
18133 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
18134 const timezoneAbbreviation = getTimezoneAbbreviation();
18135 const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)(
18136 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
18137 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
18138 return (0,external_wp_i18n_namespaceObject.isRTL)() ? `${timezoneAbbreviation} ${formattedDate}` : `${formattedDate} ${timezoneAbbreviation}`;
18139 }
18140 function getPostScheduleLabel(dateAttribute, {
18141 isFloating = false,
18142 now = new Date()
18143 } = {}) {
18144 if (!dateAttribute || isFloating) {
18145 return (0,external_wp_i18n_namespaceObject.__)('Immediately');
18146 }
18147
18148 // If the user timezone does not equal the site timezone then using words
18149 // like 'tomorrow' is confusing, so show the full date.
18150 if (!isTimezoneSameAsSiteTimezone(now)) {
18151 return getFullPostScheduleLabel(dateAttribute);
18152 }
18153 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
18154 if (isSameDay(date, now)) {
18155 return (0,external_wp_i18n_namespaceObject.sprintf)(
18156 // translators: %s: Time of day the post is scheduled for.
18157 (0,external_wp_i18n_namespaceObject.__)('Today at %s'),
18158 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
18159 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
18160 }
18161 const tomorrow = new Date(now);
18162 tomorrow.setDate(tomorrow.getDate() + 1);
18163 if (isSameDay(date, tomorrow)) {
18164 return (0,external_wp_i18n_namespaceObject.sprintf)(
18165 // translators: %s: Time of day the post is scheduled for.
18166 (0,external_wp_i18n_namespaceObject.__)('Tomorrow at %s'),
18167 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
18168 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
18169 }
18170 if (date.getFullYear() === now.getFullYear()) {
18171 return (0,external_wp_date_namespaceObject.dateI18n)(
18172 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
18173 (0,external_wp_i18n_namespaceObject._x)('F j g:i\xa0a', 'post schedule date format without year'), date);
18174 }
18175 return (0,external_wp_date_namespaceObject.dateI18n)(
18176 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
18177 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
18178 }
18179 function getTimezoneAbbreviation() {
18180 const {
18181 timezone
18182 } = (0,external_wp_date_namespaceObject.getSettings)();
18183 if (timezone.abbr && isNaN(Number(timezone.abbr))) {
18184 return timezone.abbr;
18185 }
18186 const symbol = timezone.offset < 0 ? '' : '+';
18187 return `UTC${symbol}${timezone.offsetFormatted}`;
18188 }
18189 function isTimezoneSameAsSiteTimezone(date) {
18190 const {
18191 timezone
18192 } = (0,external_wp_date_namespaceObject.getSettings)();
18193 const siteOffset = Number(timezone.offset);
18194 const dateOffset = -1 * (date.getTimezoneOffset() / 60);
18195 return siteOffset === dateOffset;
18196 }
18197 function isSameDay(left, right) {
18198 return left.getDate() === right.getDate() && left.getMonth() === right.getMonth() && left.getFullYear() === right.getFullYear();
18199 }
18200
18201 ;// ./packages/editor/build-module/components/post-taxonomies/most-used-terms.js
18202 /**
18203 * WordPress dependencies
18204 */
18205
18206
18207
18208
18209 /**
18210 * Internal dependencies
18211 */
18212
18213
18214 const MIN_MOST_USED_TERMS = 3;
18215 const DEFAULT_QUERY = {
18216 per_page: 10,
18217 orderby: 'count',
18218 order: 'desc',
18219 hide_empty: true,
18220 _fields: 'id,name,count',
18221 context: 'view'
18222 };
18223 function MostUsedTerms({
18224 onSelect,
18225 taxonomy
18226 }) {
18227 const {
18228 _terms,
18229 showTerms
18230 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18231 const mostUsedTerms = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY);
18232 return {
18233 _terms: mostUsedTerms,
18234 showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS
18235 };
18236 }, [taxonomy.slug]);
18237 if (!showTerms) {
18238 return null;
18239 }
18240 const terms = unescapeTerms(_terms);
18241 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18242 className: "editor-post-taxonomies__flat-term-most-used",
18243 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
18244 as: "h3",
18245 className: "editor-post-taxonomies__flat-term-most-used-label",
18246 children: taxonomy.labels.most_used
18247 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
18248 role: "list",
18249 className: "editor-post-taxonomies__flat-term-most-used-list",
18250 children: terms.map(term => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
18251 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18252 __next40pxDefaultSize: true,
18253 variant: "link",
18254 onClick: () => onSelect(term),
18255 children: term.name
18256 })
18257 }, term.id))
18258 })]
18259 });
18260 }
18261
18262 ;// ./packages/editor/build-module/components/post-taxonomies/flat-term-selector.js
18263 /**
18264 * WordPress dependencies
18265 */
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276 /**
18277 * Internal dependencies
18278 */
18279
18280
18281
18282
18283 /**
18284 * Shared reference to an empty array for cases where it is important to avoid
18285 * returning a new array reference on every invocation.
18286 *
18287 * @type {Array<any>}
18288 */
18289
18290 const flat_term_selector_EMPTY_ARRAY = [];
18291
18292 /**
18293 * How the max suggestions limit was chosen:
18294 * - Matches the `per_page` range set by the REST API.
18295 * - Can't use "unbound" query. The `FormTokenField` needs a fixed number.
18296 * - Matches default for `FormTokenField`.
18297 */
18298 const MAX_TERMS_SUGGESTIONS = 100;
18299 const flat_term_selector_DEFAULT_QUERY = {
18300 per_page: MAX_TERMS_SUGGESTIONS,
18301 _fields: 'id,name',
18302 context: 'view'
18303 };
18304 const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
18305 const termNamesToIds = (names, terms) => {
18306 return names.map(termName => terms.find(term => isSameTermName(term.name, termName))?.id).filter(id => id !== undefined);
18307 };
18308 const Wrapper = ({
18309 children,
18310 __nextHasNoMarginBottom
18311 }) => __nextHasNoMarginBottom ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
18312 spacing: 4,
18313 children: children
18314 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
18315 children: children
18316 });
18317
18318 /**
18319 * Renders a flat term selector component.
18320 *
18321 * @param {Object} props The component props.
18322 * @param {string} props.slug The slug of the taxonomy.
18323 * @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.)
18324 *
18325 * @return {JSX.Element} The rendered flat term selector component.
18326 */
18327 function FlatTermSelector({
18328 slug,
18329 __nextHasNoMarginBottom
18330 }) {
18331 var _taxonomy$labels$add_, _taxonomy$labels$sing2;
18332 const [values, setValues] = (0,external_wp_element_namespaceObject.useState)([]);
18333 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
18334 const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500);
18335 if (!__nextHasNoMarginBottom) {
18336 external_wp_deprecated_default()('Bottom margin styles for wp.editor.PostTaxonomiesFlatTermSelector', {
18337 since: '6.7',
18338 version: '7.0',
18339 hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.'
18340 });
18341 }
18342 const {
18343 terms,
18344 termIds,
18345 taxonomy,
18346 hasAssignAction,
18347 hasCreateAction,
18348 hasResolvedTerms
18349 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18350 var _post$_links, _post$_links2;
18351 const {
18352 getCurrentPost,
18353 getEditedPostAttribute
18354 } = select(store_store);
18355 const {
18356 getEntityRecords,
18357 getTaxonomy,
18358 hasFinishedResolution
18359 } = select(external_wp_coreData_namespaceObject.store);
18360 const post = getCurrentPost();
18361 const _taxonomy = getTaxonomy(slug);
18362 const _termIds = _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : flat_term_selector_EMPTY_ARRAY;
18363 const query = {
18364 ...flat_term_selector_DEFAULT_QUERY,
18365 include: _termIds?.join(','),
18366 per_page: -1
18367 };
18368 return {
18369 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
18370 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
18371 taxonomy: _taxonomy,
18372 termIds: _termIds,
18373 terms: _termIds?.length ? getEntityRecords('taxonomy', slug, query) : flat_term_selector_EMPTY_ARRAY,
18374 hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
18375 };
18376 }, [slug]);
18377 const {
18378 searchResults
18379 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18380 const {
18381 getEntityRecords
18382 } = select(external_wp_coreData_namespaceObject.store);
18383 return {
18384 searchResults: !!search ? getEntityRecords('taxonomy', slug, {
18385 ...flat_term_selector_DEFAULT_QUERY,
18386 search
18387 }) : flat_term_selector_EMPTY_ARRAY
18388 };
18389 }, [search, slug]);
18390
18391 // Update terms state only after the selectors are resolved.
18392 // We're using this to avoid terms temporarily disappearing on slow networks
18393 // while core data makes REST API requests.
18394 (0,external_wp_element_namespaceObject.useEffect)(() => {
18395 if (hasResolvedTerms) {
18396 const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
18397 setValues(newValues);
18398 }
18399 }, [terms, hasResolvedTerms]);
18400 const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => {
18401 return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
18402 }, [searchResults]);
18403 const {
18404 editPost
18405 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18406 const {
18407 saveEntityRecord
18408 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
18409 const {
18410 createErrorNotice
18411 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
18412 if (!hasAssignAction) {
18413 return null;
18414 }
18415 async function findOrCreateTerm(term) {
18416 try {
18417 const newTerm = await saveEntityRecord('taxonomy', slug, term, {
18418 throwOnError: true
18419 });
18420 return unescapeTerm(newTerm);
18421 } catch (error) {
18422 if (error.code !== 'term_exists') {
18423 throw error;
18424 }
18425 return {
18426 id: error.data.term_id,
18427 name: term.name
18428 };
18429 }
18430 }
18431 function onUpdateTerms(newTermIds) {
18432 editPost({
18433 [taxonomy.rest_base]: newTermIds
18434 });
18435 }
18436 function onChange(termNames) {
18437 const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
18438 const uniqueTerms = termNames.reduce((acc, name) => {
18439 if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) {
18440 acc.push(name);
18441 }
18442 return acc;
18443 }, []);
18444 const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName)));
18445
18446 // Optimistically update term values.
18447 // The selector will always re-fetch terms later.
18448 setValues(uniqueTerms);
18449 if (newTermNames.length === 0) {
18450 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
18451 return;
18452 }
18453 if (!hasCreateAction) {
18454 return;
18455 }
18456 Promise.all(newTermNames.map(termName => findOrCreateTerm({
18457 name: termName
18458 }))).then(newTerms => {
18459 const newAvailableTerms = availableTerms.concat(newTerms);
18460 onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
18461 }).catch(error => {
18462 createErrorNotice(error.message, {
18463 type: 'snackbar'
18464 });
18465 // In case of a failure, try assigning available terms.
18466 // This will invalidate the optimistic update.
18467 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
18468 });
18469 }
18470 function appendTerm(newTerm) {
18471 var _taxonomy$labels$sing;
18472 if (termIds.includes(newTerm.id)) {
18473 return;
18474 }
18475 const newTermIds = [...termIds, newTerm.id];
18476 const defaultName = slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term');
18477 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
18478 (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);
18479 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
18480 onUpdateTerms(newTermIds);
18481 }
18482 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');
18483 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');
18484 const termAddedLabel = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
18485 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), singularName);
18486 const termRemovedLabel = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
18487 (0,external_wp_i18n_namespaceObject._x)('%s removed', 'term'), singularName);
18488 const removeTermLabel = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
18489 (0,external_wp_i18n_namespaceObject._x)('Remove %s', 'term'), singularName);
18490 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Wrapper, {
18491 __nextHasNoMarginBottom: __nextHasNoMarginBottom,
18492 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FormTokenField, {
18493 __next40pxDefaultSize: true,
18494 value: values,
18495 suggestions: suggestions,
18496 onChange: onChange,
18497 onInputChange: debouncedSearch,
18498 maxSuggestions: MAX_TERMS_SUGGESTIONS,
18499 label: newTermLabel,
18500 messages: {
18501 added: termAddedLabel,
18502 removed: termRemovedLabel,
18503 remove: removeTermLabel
18504 },
18505 __nextHasNoMarginBottom: __nextHasNoMarginBottom
18506 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MostUsedTerms, {
18507 taxonomy: taxonomy,
18508 onSelect: appendTerm
18509 })]
18510 });
18511 }
18512 /* harmony default export */ const flat_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(FlatTermSelector));
18513
18514 ;// ./packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.js
18515 /**
18516 * WordPress dependencies
18517 */
18518
18519
18520
18521
18522
18523
18524 /**
18525 * Internal dependencies
18526 */
18527
18528
18529
18530 const TagsPanel = () => {
18531 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18532 className: "editor-post-publish-panel__link",
18533 children: (0,external_wp_i18n_namespaceObject.__)('Add tags')
18534 }, "label")];
18535 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
18536 initialOpen: false,
18537 title: panelBodyTitle,
18538 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
18539 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.')
18540 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(flat_term_selector, {
18541 slug: "post_tag",
18542 __nextHasNoMarginBottom: true
18543 })]
18544 });
18545 };
18546 const MaybeTagsPanel = () => {
18547 const {
18548 hasTags,
18549 isPostTypeSupported
18550 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18551 const postType = select(store_store).getCurrentPostType();
18552 const tagsTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('post_tag');
18553 const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType);
18554 const areTagsFetched = tagsTaxonomy !== undefined;
18555 const tags = tagsTaxonomy && select(store_store).getEditedPostAttribute(tagsTaxonomy.rest_base);
18556 return {
18557 hasTags: !!tags?.length,
18558 isPostTypeSupported: areTagsFetched && _isPostTypeSupported
18559 };
18560 }, []);
18561 const [hadTagsWhenOpeningThePanel] = (0,external_wp_element_namespaceObject.useState)(hasTags);
18562 if (!isPostTypeSupported) {
18563 return null;
18564 }
18565
18566 /*
18567 * We only want to show the tag panel if the post didn't have
18568 * any tags when the user hit the Publish button.
18569 *
18570 * We can't use the prop.hasTags because it'll change to true
18571 * if the user adds a new tag within the pre-publish panel.
18572 * This would force a re-render and a new prop.hasTags check,
18573 * hiding this panel and keeping the user from adding
18574 * more than one tag.
18575 */
18576 if (!hadTagsWhenOpeningThePanel) {
18577 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TagsPanel, {});
18578 }
18579 return null;
18580 };
18581 /* harmony default export */ const maybe_tags_panel = (MaybeTagsPanel);
18582
18583 ;// ./packages/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js
18584 /**
18585 * WordPress dependencies
18586 */
18587
18588
18589
18590
18591
18592 /**
18593 * Internal dependencies
18594 */
18595
18596
18597
18598 const getSuggestion = (supportedFormats, suggestedPostFormat) => {
18599 const formats = POST_FORMATS.filter(format => supportedFormats?.includes(format.id));
18600 return formats.find(format => format.id === suggestedPostFormat);
18601 };
18602 const PostFormatSuggestion = ({
18603 suggestedPostFormat,
18604 suggestionText,
18605 onUpdatePostFormat
18606 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18607 __next40pxDefaultSize: true,
18608 variant: "link",
18609 onClick: () => onUpdatePostFormat(suggestedPostFormat),
18610 children: suggestionText
18611 });
18612 function PostFormatPanel() {
18613 const {
18614 currentPostFormat,
18615 suggestion
18616 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18617 var _select$getThemeSuppo;
18618 const {
18619 getEditedPostAttribute,
18620 getSuggestedPostFormat
18621 } = select(store_store);
18622 const supportedFormats = (_select$getThemeSuppo = select(external_wp_coreData_namespaceObject.store).getThemeSupports().formats) !== null && _select$getThemeSuppo !== void 0 ? _select$getThemeSuppo : [];
18623 return {
18624 currentPostFormat: getEditedPostAttribute('format'),
18625 suggestion: getSuggestion(supportedFormats, getSuggestedPostFormat())
18626 };
18627 }, []);
18628 const {
18629 editPost
18630 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18631 const onUpdatePostFormat = format => editPost({
18632 format
18633 });
18634 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18635 className: "editor-post-publish-panel__link",
18636 children: (0,external_wp_i18n_namespaceObject.__)('Use a post format')
18637 }, "label")];
18638 if (!suggestion || suggestion.id === currentPostFormat) {
18639 return null;
18640 }
18641 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
18642 initialOpen: false,
18643 title: panelBodyTitle,
18644 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
18645 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.')
18646 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
18647 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormatSuggestion, {
18648 onUpdatePostFormat: onUpdatePostFormat,
18649 suggestedPostFormat: suggestion.id,
18650 suggestionText: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: post format */
18651 (0,external_wp_i18n_namespaceObject.__)('Apply the "%1$s" format.'), suggestion.caption)
18652 })
18653 })]
18654 });
18655 }
18656
18657 ;// ./packages/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js
18658 /**
18659 * WordPress dependencies
18660 */
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671 /**
18672 * Internal dependencies
18673 */
18674
18675
18676
18677 /**
18678 * Module Constants
18679 */
18680
18681 const hierarchical_term_selector_DEFAULT_QUERY = {
18682 per_page: -1,
18683 orderby: 'name',
18684 order: 'asc',
18685 _fields: 'id,name,parent',
18686 context: 'view'
18687 };
18688 const MIN_TERMS_COUNT_FOR_FILTER = 8;
18689 const hierarchical_term_selector_EMPTY_ARRAY = [];
18690
18691 /**
18692 * Sort Terms by Selected.
18693 *
18694 * @param {Object[]} termsTree Array of terms in tree format.
18695 * @param {number[]} terms Selected terms.
18696 *
18697 * @return {Object[]} Sorted array of terms.
18698 */
18699 function sortBySelected(termsTree, terms) {
18700 const treeHasSelection = termTree => {
18701 if (terms.indexOf(termTree.id) !== -1) {
18702 return true;
18703 }
18704 if (undefined === termTree.children) {
18705 return false;
18706 }
18707 return termTree.children.map(treeHasSelection).filter(child => child).length > 0;
18708 };
18709 const termOrChildIsSelected = (termA, termB) => {
18710 const termASelected = treeHasSelection(termA);
18711 const termBSelected = treeHasSelection(termB);
18712 if (termASelected === termBSelected) {
18713 return 0;
18714 }
18715 if (termASelected && !termBSelected) {
18716 return -1;
18717 }
18718 if (!termASelected && termBSelected) {
18719 return 1;
18720 }
18721 return 0;
18722 };
18723 const newTermTree = [...termsTree];
18724 newTermTree.sort(termOrChildIsSelected);
18725 return newTermTree;
18726 }
18727
18728 /**
18729 * Find term by parent id or name.
18730 *
18731 * @param {Object[]} terms Array of Terms.
18732 * @param {number|string} parent id.
18733 * @param {string} name Term name.
18734 * @return {Object} Term object.
18735 */
18736 function findTerm(terms, parent, name) {
18737 return terms.find(term => {
18738 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase();
18739 });
18740 }
18741
18742 /**
18743 * Get filter matcher function.
18744 *
18745 * @param {string} filterValue Filter value.
18746 * @return {(function(Object): (Object|boolean))} Matcher function.
18747 */
18748 function getFilterMatcher(filterValue) {
18749 const matchTermsForFilter = originalTerm => {
18750 if ('' === filterValue) {
18751 return originalTerm;
18752 }
18753
18754 // Shallow clone, because we'll be filtering the term's children and
18755 // don't want to modify the original term.
18756 const term = {
18757 ...originalTerm
18758 };
18759
18760 // Map and filter the children, recursive so we deal with grandchildren
18761 // and any deeper levels.
18762 if (term.children.length > 0) {
18763 term.children = term.children.map(matchTermsForFilter).filter(child => child);
18764 }
18765
18766 // If the term's name contains the filterValue, or it has children
18767 // (i.e. some child matched at some point in the tree) then return it.
18768 if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) {
18769 return term;
18770 }
18771
18772 // Otherwise, return false. After mapping, the list of terms will need
18773 // to have false values filtered out.
18774 return false;
18775 };
18776 return matchTermsForFilter;
18777 }
18778
18779 /**
18780 * Hierarchical term selector.
18781 *
18782 * @param {Object} props Component props.
18783 * @param {string} props.slug Taxonomy slug.
18784 * @return {Element} Hierarchical term selector component.
18785 */
18786 function HierarchicalTermSelector({
18787 slug
18788 }) {
18789 var _taxonomy$labels$sear, _taxonomy$name;
18790 const [adding, setAdding] = (0,external_wp_element_namespaceObject.useState)(false);
18791 const [formName, setFormName] = (0,external_wp_element_namespaceObject.useState)('');
18792 /**
18793 * @type {[number|'', Function]}
18794 */
18795 const [formParent, setFormParent] = (0,external_wp_element_namespaceObject.useState)('');
18796 const [showForm, setShowForm] = (0,external_wp_element_namespaceObject.useState)(false);
18797 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
18798 const [filteredTermsTree, setFilteredTermsTree] = (0,external_wp_element_namespaceObject.useState)([]);
18799 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
18800 const {
18801 hasCreateAction,
18802 hasAssignAction,
18803 terms,
18804 loading,
18805 availableTerms,
18806 taxonomy
18807 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18808 var _post$_links, _post$_links2;
18809 const {
18810 getCurrentPost,
18811 getEditedPostAttribute
18812 } = select(store_store);
18813 const {
18814 getTaxonomy,
18815 getEntityRecords,
18816 isResolving
18817 } = select(external_wp_coreData_namespaceObject.store);
18818 const _taxonomy = getTaxonomy(slug);
18819 const post = getCurrentPost();
18820 return {
18821 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
18822 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
18823 terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : hierarchical_term_selector_EMPTY_ARRAY,
18824 loading: isResolving('getEntityRecords', ['taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY]),
18825 availableTerms: getEntityRecords('taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY) || hierarchical_term_selector_EMPTY_ARRAY,
18826 taxonomy: _taxonomy
18827 };
18828 }, [slug]);
18829 const {
18830 editPost
18831 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18832 const {
18833 saveEntityRecord
18834 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
18835 const availableTermsTree = (0,external_wp_element_namespaceObject.useMemo)(() => sortBySelected(buildTermsTree(availableTerms), terms),
18836 // Remove `terms` from the dependency list to avoid reordering every time
18837 // checking or unchecking a term.
18838 [availableTerms]);
18839 const {
18840 createErrorNotice
18841 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
18842 if (!hasAssignAction) {
18843 return null;
18844 }
18845
18846 /**
18847 * Append new term.
18848 *
18849 * @param {Object} term Term object.
18850 * @return {Promise} A promise that resolves to save term object.
18851 */
18852 const addTerm = term => {
18853 return saveEntityRecord('taxonomy', slug, term, {
18854 throwOnError: true
18855 });
18856 };
18857
18858 /**
18859 * Update terms for post.
18860 *
18861 * @param {number[]} termIds Term ids.
18862 */
18863 const onUpdateTerms = termIds => {
18864 editPost({
18865 [taxonomy.rest_base]: termIds
18866 });
18867 };
18868
18869 /**
18870 * Handler for checking term.
18871 *
18872 * @param {number} termId
18873 */
18874 const onChange = termId => {
18875 const hasTerm = terms.includes(termId);
18876 const newTerms = hasTerm ? terms.filter(id => id !== termId) : [...terms, termId];
18877 onUpdateTerms(newTerms);
18878 };
18879 const onChangeFormName = value => {
18880 setFormName(value);
18881 };
18882
18883 /**
18884 * Handler for changing form parent.
18885 *
18886 * @param {number|''} parentId Parent post id.
18887 */
18888 const onChangeFormParent = parentId => {
18889 setFormParent(parentId);
18890 };
18891 const onToggleForm = () => {
18892 setShowForm(!showForm);
18893 };
18894 const onAddTerm = async event => {
18895 var _taxonomy$labels$sing;
18896 event.preventDefault();
18897 if (formName === '' || adding) {
18898 return;
18899 }
18900
18901 // Check if the term we are adding already exists.
18902 const existingTerm = findTerm(availableTerms, formParent, formName);
18903 if (existingTerm) {
18904 // If the term we are adding exists but is not selected select it.
18905 if (!terms.some(term => term === existingTerm.id)) {
18906 onUpdateTerms([...terms, existingTerm.id]);
18907 }
18908 setFormName('');
18909 setFormParent('');
18910 return;
18911 }
18912 setAdding(true);
18913 let newTerm;
18914 try {
18915 newTerm = await addTerm({
18916 name: formName,
18917 parent: formParent ? formParent : undefined
18918 });
18919 } catch (error) {
18920 createErrorNotice(error.message, {
18921 type: 'snackbar'
18922 });
18923 return;
18924 }
18925 const defaultName = slug === 'category' ? (0,external_wp_i18n_namespaceObject.__)('Category') : (0,external_wp_i18n_namespaceObject.__)('Term');
18926 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
18927 (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);
18928 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
18929 setAdding(false);
18930 setFormName('');
18931 setFormParent('');
18932 onUpdateTerms([...terms, newTerm.id]);
18933 };
18934 const setFilter = value => {
18935 const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter(term => term);
18936 const getResultCount = termsTree => {
18937 let count = 0;
18938 for (let i = 0; i < termsTree.length; i++) {
18939 count++;
18940 if (undefined !== termsTree[i].children) {
18941 count += getResultCount(termsTree[i].children);
18942 }
18943 }
18944 return count;
18945 };
18946 setFilterValue(value);
18947 setFilteredTermsTree(newFilteredTermsTree);
18948 const resultCount = getResultCount(newFilteredTermsTree);
18949 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %d: number of results. */
18950 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', resultCount), resultCount);
18951 debouncedSpeak(resultsFoundMessage, 'assertive');
18952 };
18953 const renderTerms = renderedTerms => {
18954 return renderedTerms.map(term => {
18955 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18956 className: "editor-post-taxonomies__hierarchical-terms-choice",
18957 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
18958 __nextHasNoMarginBottom: true,
18959 checked: terms.indexOf(term.id) !== -1,
18960 onChange: () => {
18961 const termId = parseInt(term.id, 10);
18962 onChange(termId);
18963 },
18964 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(term.name)
18965 }), !!term.children.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
18966 className: "editor-post-taxonomies__hierarchical-terms-subchoices",
18967 children: renderTerms(term.children)
18968 })]
18969 }, term.id);
18970 });
18971 };
18972 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => {
18973 var _taxonomy$labels$labe;
18974 return (_taxonomy$labels$labe = taxonomy?.labels?.[labelProperty]) !== null && _taxonomy$labels$labe !== void 0 ? _taxonomy$labels$labe : slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory;
18975 };
18976 const newTermButtonLabel = labelWithFallback('add_new_item', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
18977 const newTermLabel = labelWithFallback('new_item_name', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
18978 const parentSelectLabel = labelWithFallback('parent_item', (0,external_wp_i18n_namespaceObject.__)('Parent Category'), (0,external_wp_i18n_namespaceObject.__)('Parent Term'));
18979 const noParentOption = `— ${parentSelectLabel} —`;
18980 const newTermSubmitLabel = newTermButtonLabel;
18981 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');
18982 const groupLabel = (_taxonomy$name = taxonomy?.name) !== null && _taxonomy$name !== void 0 ? _taxonomy$name : (0,external_wp_i18n_namespaceObject.__)('Terms');
18983 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
18984 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
18985 direction: "column",
18986 gap: "4",
18987 children: [showFilter && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SearchControl, {
18988 __next40pxDefaultSize: true,
18989 __nextHasNoMarginBottom: true,
18990 label: filterLabel,
18991 placeholder: filterLabel,
18992 value: filterValue,
18993 onChange: setFilter
18994 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
18995 className: "editor-post-taxonomies__hierarchical-terms-list",
18996 tabIndex: "0",
18997 role: "group",
18998 "aria-label": groupLabel,
18999 children: renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)
19000 }), !loading && hasCreateAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
19001 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19002 __next40pxDefaultSize: true,
19003 onClick: onToggleForm,
19004 className: "editor-post-taxonomies__hierarchical-terms-add",
19005 "aria-expanded": showForm,
19006 variant: "link",
19007 children: newTermButtonLabel
19008 })
19009 }), showForm && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
19010 onSubmit: onAddTerm,
19011 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
19012 direction: "column",
19013 gap: "4",
19014 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
19015 __next40pxDefaultSize: true,
19016 __nextHasNoMarginBottom: true,
19017 className: "editor-post-taxonomies__hierarchical-terms-input",
19018 label: newTermLabel,
19019 value: formName,
19020 onChange: onChangeFormName,
19021 required: true
19022 }), !!availableTerms.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TreeSelect, {
19023 __next40pxDefaultSize: true,
19024 __nextHasNoMarginBottom: true,
19025 label: parentSelectLabel,
19026 noOptionLabel: noParentOption,
19027 onChange: onChangeFormParent,
19028 selectedId: formParent,
19029 tree: availableTermsTree
19030 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
19031 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19032 __next40pxDefaultSize: true,
19033 variant: "secondary",
19034 type: "submit",
19035 className: "editor-post-taxonomies__hierarchical-terms-submit",
19036 children: newTermSubmitLabel
19037 })
19038 })]
19039 })
19040 })]
19041 });
19042 }
19043 /* harmony default export */ const hierarchical_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(HierarchicalTermSelector));
19044
19045 ;// ./packages/editor/build-module/components/post-publish-panel/maybe-category-panel.js
19046 /**
19047 * WordPress dependencies
19048 */
19049
19050
19051
19052
19053
19054
19055 /**
19056 * Internal dependencies
19057 */
19058
19059
19060
19061 function MaybeCategoryPanel() {
19062 const hasNoCategory = (0,external_wp_data_namespaceObject.useSelect)(select => {
19063 const postType = select(store_store).getCurrentPostType();
19064 const {
19065 canUser,
19066 getEntityRecord,
19067 getTaxonomy
19068 } = select(external_wp_coreData_namespaceObject.store);
19069 const categoriesTaxonomy = getTaxonomy('category');
19070 const defaultCategoryId = canUser('read', {
19071 kind: 'root',
19072 name: 'site'
19073 }) ? getEntityRecord('root', 'site')?.default_category : undefined;
19074 const defaultCategory = defaultCategoryId ? getEntityRecord('taxonomy', 'category', defaultCategoryId) : undefined;
19075 const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some(type => type === postType);
19076 const categories = categoriesTaxonomy && select(store_store).getEditedPostAttribute(categoriesTaxonomy.rest_base);
19077
19078 // This boolean should return true if everything is loaded
19079 // ( categoriesTaxonomy, defaultCategory )
19080 // and the post has not been assigned a category different than "uncategorized".
19081 return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]);
19082 }, []);
19083 const [shouldShowPanel, setShouldShowPanel] = (0,external_wp_element_namespaceObject.useState)(false);
19084 (0,external_wp_element_namespaceObject.useEffect)(() => {
19085 // We use state to avoid hiding the panel if the user edits the categories
19086 // and adds one within the panel itself (while visible).
19087 if (hasNoCategory) {
19088 setShouldShowPanel(true);
19089 }
19090 }, [hasNoCategory]);
19091 if (!shouldShowPanel) {
19092 return null;
19093 }
19094 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
19095 className: "editor-post-publish-panel__link",
19096 children: (0,external_wp_i18n_namespaceObject.__)('Assign a category')
19097 }, "label")];
19098 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
19099 initialOpen: false,
19100 title: panelBodyTitle,
19101 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
19102 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.')
19103 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(hierarchical_term_selector, {
19104 slug: "category"
19105 })]
19106 });
19107 }
19108 /* harmony default export */ const maybe_category_panel = (MaybeCategoryPanel);
19109
19110 ;// ./node_modules/uuid/dist/esm-browser/native.js
19111 const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
19112 /* harmony default export */ const esm_browser_native = ({
19113 randomUUID
19114 });
19115 ;// ./node_modules/uuid/dist/esm-browser/rng.js
19116 // Unique ID creation requires a high quality random # generator. In the browser we therefore
19117 // require the crypto API and do not support built-in fallback to lower quality random number
19118 // generators (like Math.random()).
19119 let getRandomValues;
19120 const rnds8 = new Uint8Array(16);
19121 function rng() {
19122 // lazy load so that environments that need to polyfill have a chance to do so
19123 if (!getRandomValues) {
19124 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
19125 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
19126
19127 if (!getRandomValues) {
19128 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
19129 }
19130 }
19131
19132 return getRandomValues(rnds8);
19133 }
19134 ;// ./node_modules/uuid/dist/esm-browser/stringify.js
19135
19136 /**
19137 * Convert array of 16 byte values to UUID string format of the form:
19138 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
19139 */
19140
19141 const byteToHex = [];
19142
19143 for (let i = 0; i < 256; ++i) {
19144 byteToHex.push((i + 0x100).toString(16).slice(1));
19145 }
19146
19147 function unsafeStringify(arr, offset = 0) {
19148 // Note: Be careful editing this code! It's been tuned for performance
19149 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
19150 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]];
19151 }
19152
19153 function stringify(arr, offset = 0) {
19154 const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
19155 // of the following:
19156 // - One or more input array values don't map to a hex octet (leading to
19157 // "undefined" in the uuid)
19158 // - Invalid input values for the RFC `version` or `variant` fields
19159
19160 if (!validate(uuid)) {
19161 throw TypeError('Stringified UUID is invalid');
19162 }
19163
19164 return uuid;
19165 }
19166
19167 /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify)));
19168 ;// ./node_modules/uuid/dist/esm-browser/v4.js
19169
19170
19171
19172
19173 function v4(options, buf, offset) {
19174 if (esm_browser_native.randomUUID && !buf && !options) {
19175 return esm_browser_native.randomUUID();
19176 }
19177
19178 options = options || {};
19179 const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
19180
19181 rnds[6] = rnds[6] & 0x0f | 0x40;
19182 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
19183
19184 if (buf) {
19185 offset = offset || 0;
19186
19187 for (let i = 0; i < 16; ++i) {
19188 buf[offset + i] = rnds[i];
19189 }
19190
19191 return buf;
19192 }
19193
19194 return unsafeStringify(rnds);
19195 }
19196
19197 /* harmony default export */ const esm_browser_v4 = (v4);
19198 ;// ./packages/editor/build-module/components/post-publish-panel/media-util.js
19199 /* wp:polyfill */
19200 /**
19201 * External dependencies
19202 */
19203
19204
19205 /**
19206 * WordPress dependencies
19207 */
19208
19209
19210 /**
19211 * Generate a list of unique basenames given a list of URLs.
19212 *
19213 * We want all basenames to be unique, since sometimes the extension
19214 * doesn't reflect the mime type, and may end up getting changed by
19215 * the server, on upload.
19216 *
19217 * @param {string[]} urls The list of URLs
19218 * @return {Record< string, string >} A URL => basename record.
19219 */
19220 function generateUniqueBasenames(urls) {
19221 const basenames = new Set();
19222 return Object.fromEntries(urls.map(url => {
19223 // We prefer to match the remote filename, if possible.
19224 const filename = (0,external_wp_url_namespaceObject.getFilename)(url);
19225 let basename = '';
19226 if (filename) {
19227 const parts = filename.split('.');
19228 if (parts.length > 1) {
19229 // Assume the last part is the extension.
19230 parts.pop();
19231 }
19232 basename = parts.join('.');
19233 }
19234 if (!basename) {
19235 // It looks like we don't have a basename, so let's use a UUID.
19236 basename = esm_browser_v4();
19237 }
19238 if (basenames.has(basename)) {
19239 // Append a UUID to deduplicate the basename.
19240 // The server will try to deduplicate on its own if we don't do this,
19241 // but it may run into a race condition
19242 // (see https://github.com/WordPress/gutenberg/issues/64899).
19243 // Deduplicating the filenames before uploading is safer.
19244 basename = `${basename}-${esm_browser_v4()}`;
19245 }
19246 basenames.add(basename);
19247 return [url, basename];
19248 }));
19249 }
19250
19251 /**
19252 * Fetch a list of URLs, turning those into promises for files with
19253 * unique filenames.
19254 *
19255 * @param {string[]} urls The list of URLs
19256 * @return {Record< string, Promise< File > >} A URL => File promise record.
19257 */
19258 function fetchMedia(urls) {
19259 return Object.fromEntries(Object.entries(generateUniqueBasenames(urls)).map(([url, basename]) => {
19260 const filePromise = window.fetch(url.includes('?') ? url : url + '?').then(response => response.blob()).then(blob => {
19261 // The server will reject the upload if it doesn't have an extension,
19262 // even though it'll rewrite the file name to match the mime type.
19263 // Here we provide it with a safe extension to get it past that check.
19264 return new File([blob], `${basename}.png`, {
19265 type: blob.type
19266 });
19267 });
19268 return [url, filePromise];
19269 }));
19270 }
19271
19272 ;// ./packages/editor/build-module/components/post-publish-panel/maybe-upload-media.js
19273 /* wp:polyfill */
19274 /**
19275 * WordPress dependencies
19276 */
19277
19278
19279
19280
19281
19282
19283
19284 /**
19285 * Internal dependencies
19286 */
19287
19288
19289 function flattenBlocks(blocks) {
19290 const result = [];
19291 blocks.forEach(block => {
19292 result.push(block);
19293 result.push(...flattenBlocks(block.innerBlocks));
19294 });
19295 return result;
19296 }
19297
19298 /**
19299 * Determine whether a block has external media.
19300 *
19301 * Different blocks use different attribute names (and potentially
19302 * different logic as well) in determining whether the media is
19303 * present, and whether it's external.
19304 *
19305 * @param {{name: string, attributes: Object}} block The block.
19306 * @return {boolean?} Whether the block has external media
19307 */
19308 function hasExternalMedia(block) {
19309 if (block.name === 'core/image' || block.name === 'core/cover') {
19310 return block.attributes.url && !block.attributes.id;
19311 }
19312 if (block.name === 'core/media-text') {
19313 return block.attributes.mediaUrl && !block.attributes.mediaId;
19314 }
19315 return undefined;
19316 }
19317
19318 /**
19319 * Retrieve media info from a block.
19320 *
19321 * Different blocks use different attribute names, so we need this
19322 * function to normalize things into a consistent naming scheme.
19323 *
19324 * @param {{name: string, attributes: Object}} block The block.
19325 * @return {{url: ?string, alt: ?string, id: ?number}} The media info for the block.
19326 */
19327 function getMediaInfo(block) {
19328 if (block.name === 'core/image' || block.name === 'core/cover') {
19329 const {
19330 url,
19331 alt,
19332 id
19333 } = block.attributes;
19334 return {
19335 url,
19336 alt,
19337 id
19338 };
19339 }
19340 if (block.name === 'core/media-text') {
19341 const {
19342 mediaUrl: url,
19343 mediaAlt: alt,
19344 mediaId: id
19345 } = block.attributes;
19346 return {
19347 url,
19348 alt,
19349 id
19350 };
19351 }
19352 return {};
19353 }
19354
19355 // Image component to represent a single image in the upload dialog.
19356 function Image({
19357 clientId,
19358 alt,
19359 url
19360 }) {
19361 const {
19362 selectBlock
19363 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
19364 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.img, {
19365 tabIndex: 0,
19366 role: "button",
19367 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Select image block.'),
19368 onClick: () => {
19369 selectBlock(clientId);
19370 },
19371 onKeyDown: event => {
19372 if (event.key === 'Enter' || event.key === ' ') {
19373 selectBlock(clientId);
19374 event.preventDefault();
19375 }
19376 },
19377 alt: alt,
19378 src: url,
19379 animate: {
19380 opacity: 1
19381 },
19382 exit: {
19383 opacity: 0,
19384 scale: 0
19385 },
19386 style: {
19387 width: '32px',
19388 height: '32px',
19389 objectFit: 'cover',
19390 borderRadius: '2px',
19391 cursor: 'pointer'
19392 },
19393 whileHover: {
19394 scale: 1.08
19395 }
19396 }, clientId);
19397 }
19398 function MaybeUploadMediaPanel() {
19399 const [isUploading, setIsUploading] = (0,external_wp_element_namespaceObject.useState)(false);
19400 const [isAnimating, setIsAnimating] = (0,external_wp_element_namespaceObject.useState)(false);
19401 const [hadUploadError, setHadUploadError] = (0,external_wp_element_namespaceObject.useState)(false);
19402 const {
19403 editorBlocks,
19404 mediaUpload
19405 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
19406 editorBlocks: select(external_wp_blockEditor_namespaceObject.store).getBlocks(),
19407 mediaUpload: select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload
19408 }), []);
19409
19410 // Get a list of blocks with external media.
19411 const blocksWithExternalMedia = flattenBlocks(editorBlocks).filter(block => hasExternalMedia(block));
19412 const {
19413 updateBlockAttributes
19414 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
19415 if (!mediaUpload || !blocksWithExternalMedia.length) {
19416 return null;
19417 }
19418 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
19419 className: "editor-post-publish-panel__link",
19420 children: (0,external_wp_i18n_namespaceObject.__)('External media')
19421 }, "label")];
19422
19423 /**
19424 * Update an individual block to point to newly-added library media.
19425 *
19426 * Different blocks use different attribute names, so we need this
19427 * function to ensure we modify the correct attributes for each type.
19428 *
19429 * @param {{name: string, attributes: Object}} block The block.
19430 * @param {{id: number, url: string}} media Media library file info.
19431 */
19432 function updateBlockWithUploadedMedia(block, media) {
19433 if (block.name === 'core/image' || block.name === 'core/cover') {
19434 updateBlockAttributes(block.clientId, {
19435 id: media.id,
19436 url: media.url
19437 });
19438 }
19439 if (block.name === 'core/media-text') {
19440 updateBlockAttributes(block.clientId, {
19441 mediaId: media.id,
19442 mediaUrl: media.url
19443 });
19444 }
19445 }
19446
19447 // Handle fetching and uploading all external media in the post.
19448 function uploadImages() {
19449 setIsUploading(true);
19450 setHadUploadError(false);
19451
19452 // Multiple blocks can be using the same URL, so we
19453 // should ensure we only fetch and upload each of them once.
19454 const mediaUrls = new Set(blocksWithExternalMedia.map(block => {
19455 const {
19456 url
19457 } = getMediaInfo(block);
19458 return url;
19459 }));
19460
19461 // Create an upload promise for each URL, that we can wait for in all
19462 // blocks that make use of that media.
19463 const uploadPromises = Object.fromEntries(Object.entries(fetchMedia([...mediaUrls])).map(([url, filePromise]) => {
19464 const uploadPromise = filePromise.then(blob => new Promise((resolve, reject) => {
19465 mediaUpload({
19466 filesList: [blob],
19467 onFileChange: ([media]) => {
19468 if ((0,external_wp_blob_namespaceObject.isBlobURL)(media.url)) {
19469 return;
19470 }
19471 resolve(media);
19472 },
19473 onError() {
19474 reject();
19475 }
19476 });
19477 }));
19478 return [url, uploadPromise];
19479 }));
19480
19481 // Wait for all blocks to be updated with library media.
19482 Promise.allSettled(blocksWithExternalMedia.map(block => {
19483 const {
19484 url
19485 } = getMediaInfo(block);
19486 return uploadPromises[url].then(media => updateBlockWithUploadedMedia(block, media)).then(() => setIsAnimating(true)).catch(() => setHadUploadError(true));
19487 })).finally(() => {
19488 setIsUploading(false);
19489 });
19490 }
19491 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
19492 initialOpen: true,
19493 title: panelBodyTitle,
19494 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
19495 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.')
19496 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19497 style: {
19498 display: 'inline-flex',
19499 flexWrap: 'wrap',
19500 gap: '8px'
19501 },
19502 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
19503 onExitComplete: () => setIsAnimating(false),
19504 children: blocksWithExternalMedia.map(block => {
19505 const {
19506 url,
19507 alt
19508 } = getMediaInfo(block);
19509 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Image, {
19510 clientId: block.clientId,
19511 url: url,
19512 alt: alt
19513 }, block.clientId);
19514 })
19515 }), isUploading || isAnimating ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19516 size: "compact",
19517 variant: "primary",
19518 onClick: uploadImages,
19519 children: (0,external_wp_i18n_namespaceObject.__)('Upload')
19520 })]
19521 }), hadUploadError && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
19522 children: (0,external_wp_i18n_namespaceObject.__)('Upload failed, try again.')
19523 })]
19524 });
19525 }
19526
19527 ;// ./packages/editor/build-module/components/post-publish-panel/prepublish.js
19528 /**
19529 * WordPress dependencies
19530 */
19531
19532
19533
19534
19535
19536
19537
19538
19539 /**
19540 * Internal dependencies
19541 */
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552 function PostPublishPanelPrepublish({
19553 children
19554 }) {
19555 const {
19556 isBeingScheduled,
19557 isRequestingSiteIcon,
19558 hasPublishAction,
19559 siteIconUrl,
19560 siteTitle,
19561 siteHome
19562 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19563 var _getCurrentPost$_link;
19564 const {
19565 getCurrentPost,
19566 isEditedPostBeingScheduled
19567 } = select(store_store);
19568 const {
19569 getEntityRecord,
19570 isResolving
19571 } = select(external_wp_coreData_namespaceObject.store);
19572 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
19573 return {
19574 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
19575 isBeingScheduled: isEditedPostBeingScheduled(),
19576 isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
19577 siteIconUrl: siteData.site_icon_url,
19578 siteTitle: siteData.name,
19579 siteHome: siteData.home && (0,external_wp_url_namespaceObject.filterURLForDisplay)(siteData.home)
19580 };
19581 }, []);
19582 let siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
19583 className: "components-site-icon",
19584 size: "36px",
19585 icon: library_wordpress
19586 });
19587 if (siteIconUrl) {
19588 siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
19589 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
19590 className: "components-site-icon",
19591 src: siteIconUrl
19592 });
19593 }
19594 if (isRequestingSiteIcon) {
19595 siteIcon = null;
19596 }
19597 let prePublishTitle, prePublishBodyText;
19598 if (!hasPublishAction) {
19599 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to submit for review?');
19600 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('When you’re ready, submit your work for review, and an Editor will be able to approve it for you.');
19601 } else if (isBeingScheduled) {
19602 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to schedule?');
19603 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Your work will be published at the specified date and time.');
19604 } else {
19605 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to publish?');
19606 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Double-check your settings before publishing.');
19607 }
19608 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19609 className: "editor-post-publish-panel__prepublish",
19610 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
19611 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
19612 children: prePublishTitle
19613 })
19614 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
19615 children: prePublishBodyText
19616 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19617 className: "components-site-card",
19618 children: [siteIcon, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19619 className: "components-site-info",
19620 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
19621 className: "components-site-name",
19622 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle) || (0,external_wp_i18n_namespaceObject.__)('(Untitled)')
19623 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
19624 className: "components-site-home",
19625 children: siteHome
19626 })]
19627 })]
19628 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MaybeUploadMediaPanel, {}), hasPublishAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
19629 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
19630 initialOpen: false,
19631 title: [(0,external_wp_i18n_namespaceObject.__)('Visibility:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
19632 className: "editor-post-publish-panel__link",
19633 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityLabel, {})
19634 }, "label")],
19635 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibility, {})
19636 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
19637 initialOpen: false,
19638 title: [(0,external_wp_i18n_namespaceObject.__)('Publish:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
19639 className: "editor-post-publish-panel__link",
19640 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {})
19641 }, "label")],
19642 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {})
19643 })]
19644 }), /*#__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]
19645 });
19646 }
19647 /* harmony default export */ const prepublish = (PostPublishPanelPrepublish);
19648
19649 ;// ./packages/editor/build-module/components/post-publish-panel/postpublish.js
19650 /**
19651 * WordPress dependencies
19652 */
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662 /**
19663 * Internal dependencies
19664 */
19665
19666
19667
19668 const POSTNAME = '%postname%';
19669 const PAGENAME = '%pagename%';
19670
19671 /**
19672 * Returns URL for a future post.
19673 *
19674 * @param {Object} post Post object.
19675 *
19676 * @return {string} PostPublish URL.
19677 */
19678
19679 const getFuturePostUrl = post => {
19680 const {
19681 slug
19682 } = post;
19683 if (post.permalink_template.includes(POSTNAME)) {
19684 return post.permalink_template.replace(POSTNAME, slug);
19685 }
19686 if (post.permalink_template.includes(PAGENAME)) {
19687 return post.permalink_template.replace(PAGENAME, slug);
19688 }
19689 return post.permalink_template;
19690 };
19691 function postpublish_CopyButton({
19692 text,
19693 onCopy,
19694 children
19695 }) {
19696 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text, onCopy);
19697 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19698 __next40pxDefaultSize: true,
19699 variant: "secondary",
19700 ref: ref,
19701 children: children
19702 });
19703 }
19704 class PostPublishPanelPostpublish extends external_wp_element_namespaceObject.Component {
19705 constructor() {
19706 super(...arguments);
19707 this.state = {
19708 showCopyConfirmation: false
19709 };
19710 this.onCopy = this.onCopy.bind(this);
19711 this.onSelectInput = this.onSelectInput.bind(this);
19712 this.postLink = (0,external_wp_element_namespaceObject.createRef)();
19713 }
19714 componentDidMount() {
19715 if (this.props.focusOnMount) {
19716 this.postLink.current.focus();
19717 }
19718 }
19719 componentWillUnmount() {
19720 clearTimeout(this.dismissCopyConfirmation);
19721 }
19722 onCopy() {
19723 this.setState({
19724 showCopyConfirmation: true
19725 });
19726 clearTimeout(this.dismissCopyConfirmation);
19727 this.dismissCopyConfirmation = setTimeout(() => {
19728 this.setState({
19729 showCopyConfirmation: false
19730 });
19731 }, 4000);
19732 }
19733 onSelectInput(event) {
19734 event.target.select();
19735 }
19736 render() {
19737 const {
19738 children,
19739 isScheduled,
19740 post,
19741 postType
19742 } = this.props;
19743 const postLabel = postType?.labels?.singular_name;
19744 const viewPostLabel = postType?.labels?.view_item;
19745 const addNewPostLabel = postType?.labels?.add_new_item;
19746 const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
19747 const addLink = (0,external_wp_url_namespaceObject.addQueryArgs)('post-new.php', {
19748 post_type: post.type
19749 });
19750 const postPublishNonLinkHeader = isScheduled ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
19751 children: [(0,external_wp_i18n_namespaceObject.__)('is now scheduled. It will go live on'), ' ', /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {}), "."]
19752 }) : (0,external_wp_i18n_namespaceObject.__)('is now live.');
19753 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19754 className: "post-publish-panel__postpublish",
19755 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
19756 className: "post-publish-panel__postpublish-header",
19757 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("a", {
19758 ref: this.postLink,
19759 href: link,
19760 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title) || (0,external_wp_i18n_namespaceObject.__)('(no title)')
19761 }), ' ', postPublishNonLinkHeader]
19762 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
19763 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
19764 className: "post-publish-panel__postpublish-subheader",
19765 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
19766 children: (0,external_wp_i18n_namespaceObject.__)('What’s next?')
19767 })
19768 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19769 className: "post-publish-panel__postpublish-post-address-container",
19770 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
19771 __next40pxDefaultSize: true,
19772 __nextHasNoMarginBottom: true,
19773 className: "post-publish-panel__postpublish-post-address",
19774 readOnly: true,
19775 label: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: post type singular name */
19776 (0,external_wp_i18n_namespaceObject.__)('%s address'), postLabel),
19777 value: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(link),
19778 onFocus: this.onSelectInput
19779 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
19780 className: "post-publish-panel__postpublish-post-address__copy-button-wrap",
19781 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(postpublish_CopyButton, {
19782 text: link,
19783 onCopy: this.onCopy,
19784 children: this.state.showCopyConfirmation ? (0,external_wp_i18n_namespaceObject.__)('Copied!') : (0,external_wp_i18n_namespaceObject.__)('Copy')
19785 })
19786 })]
19787 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19788 className: "post-publish-panel__postpublish-buttons",
19789 children: [!isScheduled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19790 variant: "primary",
19791 href: link,
19792 __next40pxDefaultSize: true,
19793 children: viewPostLabel
19794 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19795 variant: isScheduled ? 'primary' : 'secondary',
19796 __next40pxDefaultSize: true,
19797 href: addLink,
19798 children: addNewPostLabel
19799 })]
19800 })]
19801 }), children]
19802 });
19803 }
19804 }
19805 /* harmony default export */ const postpublish = ((0,external_wp_data_namespaceObject.withSelect)(select => {
19806 const {
19807 getEditedPostAttribute,
19808 getCurrentPost,
19809 isCurrentPostScheduled
19810 } = select(store_store);
19811 const {
19812 getPostType
19813 } = select(external_wp_coreData_namespaceObject.store);
19814 return {
19815 post: getCurrentPost(),
19816 postType: getPostType(getEditedPostAttribute('type')),
19817 isScheduled: isCurrentPostScheduled()
19818 };
19819 })(PostPublishPanelPostpublish));
19820
19821 ;// ./packages/editor/build-module/components/post-publish-panel/index.js
19822 /**
19823 * WordPress dependencies
19824 */
19825
19826
19827
19828
19829
19830
19831
19832
19833 /**
19834 * Internal dependencies
19835 */
19836
19837
19838
19839
19840
19841 class PostPublishPanel extends external_wp_element_namespaceObject.Component {
19842 constructor() {
19843 super(...arguments);
19844 this.onSubmit = this.onSubmit.bind(this);
19845 this.cancelButtonNode = (0,external_wp_element_namespaceObject.createRef)();
19846 }
19847 componentDidMount() {
19848 // This timeout is necessary to make sure the `useEffect` hook of
19849 // `useFocusReturn` gets the correct element (the button that opens the
19850 // PostPublishPanel) otherwise it will get this button.
19851 this.timeoutID = setTimeout(() => {
19852 this.cancelButtonNode.current.focus();
19853 }, 0);
19854 }
19855 componentWillUnmount() {
19856 clearTimeout(this.timeoutID);
19857 }
19858 componentDidUpdate(prevProps) {
19859 // Automatically collapse the publish sidebar when a post
19860 // is published and the user makes an edit.
19861 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) {
19862 this.props.onClose();
19863 }
19864 }
19865 onSubmit() {
19866 const {
19867 onClose,
19868 hasPublishAction,
19869 isPostTypeViewable
19870 } = this.props;
19871 if (!hasPublishAction || !isPostTypeViewable) {
19872 onClose();
19873 }
19874 }
19875 render() {
19876 const {
19877 forceIsDirty,
19878 isBeingScheduled,
19879 isPublished,
19880 isPublishSidebarEnabled,
19881 isScheduled,
19882 isSaving,
19883 isSavingNonPostEntityChanges,
19884 onClose,
19885 onTogglePublishSidebar,
19886 PostPublishExtension,
19887 PrePublishExtension,
19888 ...additionalProps
19889 } = this.props;
19890 const {
19891 hasPublishAction,
19892 isDirty,
19893 isPostTypeViewable,
19894 ...propsForPanel
19895 } = additionalProps;
19896 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled;
19897 const isPrePublish = !isPublishedOrScheduled && !isSaving;
19898 const isPostPublish = isPublishedOrScheduled && !isSaving;
19899 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19900 className: "editor-post-publish-panel",
19901 ...propsForPanel,
19902 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
19903 className: "editor-post-publish-panel__header",
19904 children: isPostPublish ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19905 size: "compact",
19906 onClick: onClose,
19907 icon: close_small,
19908 label: (0,external_wp_i18n_namespaceObject.__)('Close panel')
19909 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
19910 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
19911 className: "editor-post-publish-panel__header-cancel-button",
19912 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19913 ref: this.cancelButtonNode,
19914 accessibleWhenDisabled: true,
19915 disabled: isSavingNonPostEntityChanges,
19916 onClick: onClose,
19917 variant: "secondary",
19918 size: "compact",
19919 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
19920 })
19921 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
19922 className: "editor-post-publish-panel__header-publish-button",
19923 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
19924 onSubmit: this.onSubmit,
19925 forceIsDirty: forceIsDirty
19926 })
19927 })]
19928 })
19929 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19930 className: "editor-post-publish-panel__content",
19931 children: [isPrePublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(prepublish, {
19932 children: PrePublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrePublishExtension, {})
19933 }), isPostPublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(postpublish, {
19934 focusOnMount: true,
19935 children: PostPublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPublishExtension, {})
19936 }), isSaving && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {})]
19937 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
19938 className: "editor-post-publish-panel__footer",
19939 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
19940 __nextHasNoMarginBottom: true,
19941 label: (0,external_wp_i18n_namespaceObject.__)('Always show pre-publish checks.'),
19942 checked: isPublishSidebarEnabled,
19943 onChange: onTogglePublishSidebar
19944 })
19945 })]
19946 });
19947 }
19948 }
19949
19950 /**
19951 * Renders a panel for publishing a post.
19952 */
19953 /* harmony default export */ const post_publish_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
19954 var _getCurrentPost$_link;
19955 const {
19956 getPostType
19957 } = select(external_wp_coreData_namespaceObject.store);
19958 const {
19959 getCurrentPost,
19960 getEditedPostAttribute,
19961 isCurrentPostPublished,
19962 isCurrentPostScheduled,
19963 isEditedPostBeingScheduled,
19964 isEditedPostDirty,
19965 isAutosavingPost,
19966 isSavingPost,
19967 isSavingNonPostEntityChanges
19968 } = select(store_store);
19969 const {
19970 isPublishSidebarEnabled
19971 } = select(store_store);
19972 const postType = getPostType(getEditedPostAttribute('type'));
19973 return {
19974 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
19975 isPostTypeViewable: postType?.viewable,
19976 isBeingScheduled: isEditedPostBeingScheduled(),
19977 isDirty: isEditedPostDirty(),
19978 isPublished: isCurrentPostPublished(),
19979 isPublishSidebarEnabled: isPublishSidebarEnabled(),
19980 isSaving: isSavingPost() && !isAutosavingPost(),
19981 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
19982 isScheduled: isCurrentPostScheduled()
19983 };
19984 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
19985 isPublishSidebarEnabled
19986 }) => {
19987 const {
19988 disablePublishSidebar,
19989 enablePublishSidebar
19990 } = dispatch(store_store);
19991 return {
19992 onTogglePublishSidebar: () => {
19993 if (isPublishSidebarEnabled) {
19994 disablePublishSidebar();
19995 } else {
19996 enablePublishSidebar();
19997 }
19998 }
19999 };
20000 }), external_wp_components_namespaceObject.withFocusReturn, external_wp_components_namespaceObject.withConstrainedTabbing])(PostPublishPanel));
20001
20002 ;// ./packages/icons/build-module/library/cloud-upload.js
20003 /**
20004 * WordPress dependencies
20005 */
20006
20007
20008 const cloudUpload = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20009 xmlns: "http://www.w3.org/2000/svg",
20010 viewBox: "0 0 24 24",
20011 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20012 d: "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"
20013 })
20014 });
20015 /* harmony default export */ const cloud_upload = (cloudUpload);
20016
20017 ;// ./packages/icons/build-module/icon/index.js
20018 /**
20019 * WordPress dependencies
20020 */
20021
20022
20023 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
20024
20025 /**
20026 * Return an SVG icon.
20027 *
20028 * @param {IconProps} props icon is the SVG component to render
20029 * size is a number specifiying the icon size in pixels
20030 * Other props will be passed to wrapped SVG component
20031 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
20032 *
20033 * @return {JSX.Element} Icon component
20034 */
20035 function Icon({
20036 icon,
20037 size = 24,
20038 ...props
20039 }, ref) {
20040 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
20041 width: size,
20042 height: size,
20043 ...props,
20044 ref
20045 });
20046 }
20047 /* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
20048
20049 ;// ./packages/icons/build-module/library/cloud.js
20050 /**
20051 * WordPress dependencies
20052 */
20053
20054
20055 const cloud = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20056 xmlns: "http://www.w3.org/2000/svg",
20057 viewBox: "0 0 24 24",
20058 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20059 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"
20060 })
20061 });
20062 /* harmony default export */ const library_cloud = (cloud);
20063
20064 ;// ./packages/icons/build-module/library/drafts.js
20065 /**
20066 * WordPress dependencies
20067 */
20068
20069
20070 const drafts = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20071 xmlns: "http://www.w3.org/2000/svg",
20072 viewBox: "0 0 24 24",
20073 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20074 fillRule: "evenodd",
20075 clipRule: "evenodd",
20076 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"
20077 })
20078 });
20079 /* harmony default export */ const library_drafts = (drafts);
20080
20081 ;// ./packages/icons/build-module/library/pending.js
20082 /**
20083 * WordPress dependencies
20084 */
20085
20086
20087 const pending = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20088 xmlns: "http://www.w3.org/2000/svg",
20089 viewBox: "0 0 24 24",
20090 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20091 fillRule: "evenodd",
20092 clipRule: "evenodd",
20093 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"
20094 })
20095 });
20096 /* harmony default export */ const library_pending = (pending);
20097
20098 ;// ./packages/icons/build-module/library/not-allowed.js
20099 /**
20100 * WordPress dependencies
20101 */
20102
20103
20104 const notAllowed = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20105 xmlns: "http://www.w3.org/2000/svg",
20106 viewBox: "0 0 24 24",
20107 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20108 fillRule: "evenodd",
20109 clipRule: "evenodd",
20110 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"
20111 })
20112 });
20113 /* harmony default export */ const not_allowed = (notAllowed);
20114
20115 ;// ./packages/icons/build-module/library/scheduled.js
20116 /**
20117 * WordPress dependencies
20118 */
20119
20120
20121 const scheduled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20122 xmlns: "http://www.w3.org/2000/svg",
20123 viewBox: "0 0 24 24",
20124 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20125 fillRule: "evenodd",
20126 clipRule: "evenodd",
20127 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"
20128 })
20129 });
20130 /* harmony default export */ const library_scheduled = (scheduled);
20131
20132 ;// ./packages/icons/build-module/library/published.js
20133 /**
20134 * WordPress dependencies
20135 */
20136
20137
20138 const published = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20139 xmlns: "http://www.w3.org/2000/svg",
20140 viewBox: "0 0 24 24",
20141 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20142 fillRule: "evenodd",
20143 clipRule: "evenodd",
20144 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"
20145 })
20146 });
20147 /* harmony default export */ const library_published = (published);
20148
20149 ;// ./packages/editor/build-module/components/post-sticky/check.js
20150 /**
20151 * WordPress dependencies
20152 */
20153
20154
20155 /**
20156 * Internal dependencies
20157 */
20158
20159
20160 /**
20161 * Wrapper component that renders its children only if post has a sticky action.
20162 *
20163 * @param {Object} props Props.
20164 * @param {Element} props.children Children to be rendered.
20165 *
20166 * @return {Component} The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
20167 */
20168 function PostStickyCheck({
20169 children
20170 }) {
20171 const {
20172 hasStickyAction,
20173 postType
20174 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20175 var _post$_links$wpActio;
20176 const post = select(store_store).getCurrentPost();
20177 return {
20178 hasStickyAction: (_post$_links$wpActio = post._links?.['wp:action-sticky']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
20179 postType: select(store_store).getCurrentPostType()
20180 };
20181 }, []);
20182 if (postType !== 'post' || !hasStickyAction) {
20183 return null;
20184 }
20185 return children;
20186 }
20187
20188 ;// ./packages/editor/build-module/components/post-sticky/index.js
20189 /**
20190 * WordPress dependencies
20191 */
20192
20193
20194
20195
20196 /**
20197 * Internal dependencies
20198 */
20199
20200
20201
20202 /**
20203 * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.
20204 *
20205 * @return {Component} The component to be rendered.
20206 */
20207
20208 function PostSticky() {
20209 const postSticky = (0,external_wp_data_namespaceObject.useSelect)(select => {
20210 var _select$getEditedPost;
20211 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('sticky')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : false;
20212 }, []);
20213 const {
20214 editPost
20215 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
20216 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostStickyCheck, {
20217 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
20218 className: "editor-post-sticky__checkbox-control",
20219 label: (0,external_wp_i18n_namespaceObject.__)('Sticky'),
20220 help: (0,external_wp_i18n_namespaceObject.__)('Pin this post to the top of the blog'),
20221 checked: postSticky,
20222 onChange: () => editPost({
20223 sticky: !postSticky
20224 }),
20225 __nextHasNoMarginBottom: true
20226 })
20227 });
20228 }
20229
20230 ;// ./packages/editor/build-module/components/post-status/index.js
20231 /**
20232 * WordPress dependencies
20233 */
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243 /**
20244 * Internal dependencies
20245 */
20246
20247
20248
20249
20250
20251
20252 const postStatusesInfo = {
20253 'auto-draft': {
20254 label: (0,external_wp_i18n_namespaceObject.__)('Draft'),
20255 icon: library_drafts
20256 },
20257 draft: {
20258 label: (0,external_wp_i18n_namespaceObject.__)('Draft'),
20259 icon: library_drafts
20260 },
20261 pending: {
20262 label: (0,external_wp_i18n_namespaceObject.__)('Pending'),
20263 icon: library_pending
20264 },
20265 private: {
20266 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
20267 icon: not_allowed
20268 },
20269 future: {
20270 label: (0,external_wp_i18n_namespaceObject.__)('Scheduled'),
20271 icon: library_scheduled
20272 },
20273 publish: {
20274 label: (0,external_wp_i18n_namespaceObject.__)('Published'),
20275 icon: library_published
20276 }
20277 };
20278 const STATUS_OPTIONS = [{
20279 label: (0,external_wp_i18n_namespaceObject.__)('Draft'),
20280 value: 'draft',
20281 description: (0,external_wp_i18n_namespaceObject.__)('Not ready to publish.')
20282 }, {
20283 label: (0,external_wp_i18n_namespaceObject.__)('Pending'),
20284 value: 'pending',
20285 description: (0,external_wp_i18n_namespaceObject.__)('Waiting for review before publishing.')
20286 }, {
20287 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
20288 value: 'private',
20289 description: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
20290 }, {
20291 label: (0,external_wp_i18n_namespaceObject.__)('Scheduled'),
20292 value: 'future',
20293 description: (0,external_wp_i18n_namespaceObject.__)('Publish automatically on a chosen date.')
20294 }, {
20295 label: (0,external_wp_i18n_namespaceObject.__)('Published'),
20296 value: 'publish',
20297 description: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
20298 }];
20299 const DESIGN_POST_TYPES = [constants_TEMPLATE_POST_TYPE, constants_TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
20300 function PostStatus() {
20301 const {
20302 status,
20303 date,
20304 password,
20305 postId,
20306 postType,
20307 canEdit
20308 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20309 var _getCurrentPost$_link;
20310 const {
20311 getEditedPostAttribute,
20312 getCurrentPostId,
20313 getCurrentPostType,
20314 getCurrentPost
20315 } = select(store_store);
20316 return {
20317 status: getEditedPostAttribute('status'),
20318 date: getEditedPostAttribute('date'),
20319 password: getEditedPostAttribute('password'),
20320 postId: getCurrentPostId(),
20321 postType: getCurrentPostType(),
20322 canEdit: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
20323 };
20324 }, []);
20325 const [showPassword, setShowPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
20326 const passwordInputId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostStatus, 'editor-change-status__password-input');
20327 const {
20328 editEntityRecord
20329 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
20330 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
20331 // Memoize popoverProps to avoid returning a new object every time.
20332 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
20333 // Anchor the popover to the middle of the entire row so that it doesn't
20334 // move around when the label changes.
20335 anchor: popoverAnchor,
20336 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
20337 headerTitle: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
20338 placement: 'left-start',
20339 offset: 36,
20340 shift: true
20341 }), [popoverAnchor]);
20342 if (DESIGN_POST_TYPES.includes(postType)) {
20343 return null;
20344 }
20345 const updatePost = ({
20346 status: newStatus = status,
20347 password: newPassword = password,
20348 date: newDate = date
20349 }) => {
20350 editEntityRecord('postType', postType, postId, {
20351 status: newStatus,
20352 date: newDate,
20353 password: newPassword
20354 });
20355 };
20356 const handleTogglePassword = value => {
20357 setShowPassword(value);
20358 if (!value) {
20359 updatePost({
20360 password: ''
20361 });
20362 }
20363 };
20364 const handleStatus = value => {
20365 let newDate = date;
20366 let newPassword = password;
20367 if (status === 'future' && new Date(date) > new Date()) {
20368 newDate = null;
20369 }
20370 if (value === 'private' && password) {
20371 newPassword = '';
20372 }
20373 updatePost({
20374 status: value,
20375 date: newDate,
20376 password: newPassword
20377 });
20378 };
20379 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
20380 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
20381 ref: setPopoverAnchor,
20382 children: canEdit ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
20383 className: "editor-post-status",
20384 contentClassName: "editor-change-status__content",
20385 popoverProps: popoverProps,
20386 focusOnMount: true,
20387 renderToggle: ({
20388 onToggle,
20389 isOpen
20390 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
20391 className: "editor-post-status__toggle",
20392 variant: "tertiary",
20393 size: "compact",
20394 onClick: onToggle,
20395 icon: postStatusesInfo[status]?.icon,
20396 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
20397 // translators: %s: Current post status.
20398 (0,external_wp_i18n_namespaceObject.__)('Change status: %s'), postStatusesInfo[status]?.label),
20399 "aria-expanded": isOpen,
20400 children: postStatusesInfo[status]?.label
20401 }),
20402 renderContent: ({
20403 onClose
20404 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
20405 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
20406 title: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
20407 onClose: onClose
20408 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
20409 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
20410 spacing: 4,
20411 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
20412 className: "editor-change-status__options",
20413 hideLabelFromVision: true,
20414 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
20415 options: STATUS_OPTIONS,
20416 onChange: handleStatus,
20417 selected: status === 'auto-draft' ? 'draft' : status
20418 }), status === 'future' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20419 className: "editor-change-status__publish-date-wrapper",
20420 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
20421 showPopoverHeaderActions: false,
20422 isCompact: true
20423 })
20424 }), status !== 'private' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
20425 as: "fieldset",
20426 spacing: 4,
20427 className: "editor-change-status__password-fieldset",
20428 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
20429 __nextHasNoMarginBottom: true,
20430 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
20431 help: (0,external_wp_i18n_namespaceObject.__)('Only visible to those who know the password'),
20432 checked: showPassword,
20433 onChange: handleTogglePassword
20434 }), showPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20435 className: "editor-change-status__password-input",
20436 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
20437 label: (0,external_wp_i18n_namespaceObject.__)('Password'),
20438 onChange: value => updatePost({
20439 password: value
20440 }),
20441 value: password,
20442 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password'),
20443 type: "text",
20444 id: passwordInputId,
20445 __next40pxDefaultSize: true,
20446 __nextHasNoMarginBottom: true,
20447 maxLength: 255
20448 })
20449 })]
20450 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSticky, {})]
20451 })
20452 })]
20453 })
20454 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20455 className: "editor-post-status is-read-only",
20456 children: postStatusesInfo[status]?.label
20457 })
20458 });
20459 }
20460
20461 ;// ./packages/editor/build-module/components/post-saved-state/index.js
20462 /**
20463 * External dependencies
20464 */
20465
20466
20467 /**
20468 * WordPress dependencies
20469 */
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479 /**
20480 * Internal dependencies
20481 */
20482
20483
20484
20485 /**
20486 * Component showing whether the post is saved or not and providing save
20487 * buttons.
20488 *
20489 * @param {Object} props Component props.
20490 * @param {?boolean} props.forceIsDirty Whether to force the post to be marked
20491 * as dirty.
20492 * @return {import('react').ComponentType} The component.
20493 */
20494
20495 function PostSavedState({
20496 forceIsDirty
20497 }) {
20498 const [forceSavedMessage, setForceSavedMessage] = (0,external_wp_element_namespaceObject.useState)(false);
20499 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small');
20500 const {
20501 isAutosaving,
20502 isDirty,
20503 isNew,
20504 isPublished,
20505 isSaveable,
20506 isSaving,
20507 isScheduled,
20508 hasPublishAction,
20509 showIconLabels,
20510 postStatus,
20511 postStatusHasChanged
20512 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20513 var _getCurrentPost$_link;
20514 const {
20515 isEditedPostNew,
20516 isCurrentPostPublished,
20517 isCurrentPostScheduled,
20518 isEditedPostDirty,
20519 isSavingPost,
20520 isEditedPostSaveable,
20521 getCurrentPost,
20522 isAutosavingPost,
20523 getEditedPostAttribute,
20524 getPostEdits
20525 } = select(store_store);
20526 const {
20527 get
20528 } = select(external_wp_preferences_namespaceObject.store);
20529 return {
20530 isAutosaving: isAutosavingPost(),
20531 isDirty: forceIsDirty || isEditedPostDirty(),
20532 isNew: isEditedPostNew(),
20533 isPublished: isCurrentPostPublished(),
20534 isSaving: isSavingPost(),
20535 isSaveable: isEditedPostSaveable(),
20536 isScheduled: isCurrentPostScheduled(),
20537 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
20538 showIconLabels: get('core', 'showIconLabels'),
20539 postStatus: getEditedPostAttribute('status'),
20540 postStatusHasChanged: !!getPostEdits()?.status
20541 };
20542 }, [forceIsDirty]);
20543 const isPending = postStatus === 'pending';
20544 const {
20545 savePost
20546 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
20547 const wasSaving = (0,external_wp_compose_namespaceObject.usePrevious)(isSaving);
20548 (0,external_wp_element_namespaceObject.useEffect)(() => {
20549 let timeoutId;
20550 if (wasSaving && !isSaving) {
20551 setForceSavedMessage(true);
20552 timeoutId = setTimeout(() => {
20553 setForceSavedMessage(false);
20554 }, 1000);
20555 }
20556 return () => clearTimeout(timeoutId);
20557 }, [isSaving]);
20558
20559 // Once the post has been submitted for review this button
20560 // is not needed for the contributor role.
20561 if (!hasPublishAction && isPending) {
20562 return null;
20563 }
20564
20565 // We shouldn't render the button if the post has not one of the following statuses: pending, draft, auto-draft.
20566 // The reason for this is that this button handles the `save as pending` and `save draft` actions.
20567 // An exception for this is when the post has a custom status and there should be a way to save changes without
20568 // having to publish. This should be handled better in the future when custom statuses have better support.
20569 // @see https://github.com/WordPress/gutenberg/issues/3144.
20570 const isIneligibleStatus = !['pending', 'draft', 'auto-draft'].includes(postStatus) && STATUS_OPTIONS.map(({
20571 value
20572 }) => value).includes(postStatus);
20573 if (isPublished || isScheduled || isIneligibleStatus || postStatusHasChanged && ['pending', 'draft'].includes(postStatus)) {
20574 return null;
20575 }
20576
20577 /* translators: button label text should, if possible, be under 16 characters. */
20578 const label = isPending ? (0,external_wp_i18n_namespaceObject.__)('Save as pending') : (0,external_wp_i18n_namespaceObject.__)('Save draft');
20579
20580 /* translators: button label text should, if possible, be under 16 characters. */
20581 const shortLabel = (0,external_wp_i18n_namespaceObject.__)('Save');
20582 const isSaved = forceSavedMessage || !isNew && !isDirty;
20583 const isSavedState = isSaving || isSaved;
20584 const isDisabled = isSaving || isSaved || !isSaveable;
20585 let text;
20586 if (isSaving) {
20587 text = isAutosaving ? (0,external_wp_i18n_namespaceObject.__)('Autosaving') : (0,external_wp_i18n_namespaceObject.__)('Saving');
20588 } else if (isSaved) {
20589 text = (0,external_wp_i18n_namespaceObject.__)('Saved');
20590 } else if (isLargeViewport) {
20591 text = label;
20592 } else if (showIconLabels) {
20593 text = shortLabel;
20594 }
20595
20596 // Use common Button instance for all saved states so that focus is not
20597 // lost.
20598 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
20599 className: isSaveable || isSaving ? dist_clsx({
20600 'editor-post-save-draft': !isSavedState,
20601 'editor-post-saved-state': isSavedState,
20602 'is-saving': isSaving,
20603 'is-autosaving': isAutosaving,
20604 'is-saved': isSaved,
20605 [(0,external_wp_components_namespaceObject.__unstableGetAnimateClassName)({
20606 type: 'loading'
20607 })]: isSaving
20608 }) : undefined,
20609 onClick: isDisabled ? undefined : () => savePost()
20610 /*
20611 * We want the tooltip to show the keyboard shortcut only when the
20612 * button does something, i.e. when it's not disabled.
20613 */,
20614 shortcut: isDisabled ? undefined : external_wp_keycodes_namespaceObject.displayShortcut.primary('s'),
20615 variant: "tertiary",
20616 size: "compact",
20617 icon: isLargeViewport ? undefined : cloud_upload,
20618 label: text || label,
20619 "aria-disabled": isDisabled,
20620 children: [isSavedState && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
20621 icon: isSaved ? library_check : library_cloud
20622 }), text]
20623 });
20624 }
20625
20626 ;// ./packages/editor/build-module/components/post-schedule/check.js
20627 /**
20628 * WordPress dependencies
20629 */
20630
20631
20632 /**
20633 * Internal dependencies
20634 */
20635
20636
20637 /**
20638 * Wrapper component that renders its children only if post has a publish action.
20639 *
20640 * @param {Object} props Props.
20641 * @param {Element} props.children Children to be rendered.
20642 *
20643 * @return {Component} - The component to be rendered or null if there is no publish action.
20644 */
20645 function PostScheduleCheck({
20646 children
20647 }) {
20648 const hasPublishAction = (0,external_wp_data_namespaceObject.useSelect)(select => {
20649 var _select$getCurrentPos;
20650 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
20651 }, []);
20652 if (!hasPublishAction) {
20653 return null;
20654 }
20655 return children;
20656 }
20657
20658 ;// ./packages/editor/build-module/components/post-schedule/panel.js
20659 /**
20660 * WordPress dependencies
20661 */
20662
20663
20664
20665
20666
20667 /**
20668 * Internal dependencies
20669 */
20670
20671
20672
20673
20674
20675
20676
20677 const panel_DESIGN_POST_TYPES = [constants_TEMPLATE_POST_TYPE, constants_TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
20678
20679 /**
20680 * Renders the Post Schedule Panel component.
20681 *
20682 * @return {Component} The component to be rendered.
20683 */
20684 function PostSchedulePanel() {
20685 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
20686 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
20687 // Memoize popoverProps to avoid returning a new object every time.
20688 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
20689 // Anchor the popover to the middle of the entire row so that it doesn't
20690 // move around when the label changes.
20691 anchor: popoverAnchor,
20692 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Change publish date'),
20693 placement: 'left-start',
20694 offset: 36,
20695 shift: true
20696 }), [popoverAnchor]);
20697 const label = usePostScheduleLabel();
20698 const fullLabel = usePostScheduleLabel({
20699 full: true
20700 });
20701 if (panel_DESIGN_POST_TYPES.includes(postType)) {
20702 return null;
20703 }
20704 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleCheck, {
20705 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
20706 label: (0,external_wp_i18n_namespaceObject.__)('Publish'),
20707 ref: setPopoverAnchor,
20708 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
20709 popoverProps: popoverProps,
20710 focusOnMount: true,
20711 className: "editor-post-schedule__panel-dropdown",
20712 contentClassName: "editor-post-schedule__dialog",
20713 renderToggle: ({
20714 onToggle,
20715 isOpen
20716 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
20717 size: "compact",
20718 className: "editor-post-schedule__dialog-toggle",
20719 variant: "tertiary",
20720 tooltipPosition: "middle left",
20721 onClick: onToggle,
20722 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
20723 // translators: %s: Current post date.
20724 (0,external_wp_i18n_namespaceObject.__)('Change date: %s'), label),
20725 label: fullLabel,
20726 showTooltip: label !== fullLabel,
20727 "aria-expanded": isOpen,
20728 children: label
20729 }),
20730 renderContent: ({
20731 onClose
20732 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {
20733 onClose: onClose
20734 })
20735 })
20736 })
20737 });
20738 }
20739
20740 ;// ./packages/editor/build-module/components/post-slug/check.js
20741 /**
20742 * Internal dependencies
20743 */
20744
20745
20746 /**
20747 * Wrapper component that renders its children only if the post type supports the slug.
20748 *
20749 * @param {Object} props Props.
20750 * @param {Element} props.children Children to be rendered.
20751 *
20752 * @return {Component} The component to be rendered.
20753 */
20754
20755 function PostSlugCheck({
20756 children
20757 }) {
20758 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
20759 supportKeys: "slug",
20760 children: children
20761 });
20762 }
20763
20764 ;// ./packages/editor/build-module/components/post-slug/index.js
20765 /**
20766 * WordPress dependencies
20767 */
20768
20769
20770
20771
20772
20773
20774 /**
20775 * Internal dependencies
20776 */
20777
20778
20779
20780 function PostSlugControl() {
20781 const postSlug = (0,external_wp_data_namespaceObject.useSelect)(select => {
20782 return (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug());
20783 }, []);
20784 const {
20785 editPost
20786 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
20787 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
20788 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
20789 __next40pxDefaultSize: true,
20790 __nextHasNoMarginBottom: true,
20791 label: (0,external_wp_i18n_namespaceObject.__)('Slug'),
20792 autoComplete: "off",
20793 spellCheck: "false",
20794 value: forceEmptyField ? '' : postSlug,
20795 onChange: newValue => {
20796 editPost({
20797 slug: newValue
20798 });
20799 // When we delete the field the permalink gets
20800 // reverted to the original value.
20801 // The forceEmptyField logic allows the user to have
20802 // the field temporarily empty while typing.
20803 if (!newValue) {
20804 if (!forceEmptyField) {
20805 setForceEmptyField(true);
20806 }
20807 return;
20808 }
20809 if (forceEmptyField) {
20810 setForceEmptyField(false);
20811 }
20812 },
20813 onBlur: event => {
20814 editPost({
20815 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value)
20816 });
20817 if (forceEmptyField) {
20818 setForceEmptyField(false);
20819 }
20820 },
20821 className: "editor-post-slug"
20822 });
20823 }
20824
20825 /**
20826 * Renders the PostSlug component. It provide a control for editing the post slug.
20827 *
20828 * @return {Component} The component to be rendered.
20829 */
20830 function PostSlug() {
20831 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSlugCheck, {
20832 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSlugControl, {})
20833 });
20834 }
20835
20836 ;// ./packages/editor/build-module/components/post-switch-to-draft-button/index.js
20837 /**
20838 * WordPress dependencies
20839 */
20840
20841
20842
20843
20844
20845
20846 /**
20847 * Internal dependencies
20848 */
20849
20850
20851 /**
20852 * Renders a button component that allows the user to switch a post to draft status.
20853 *
20854 * @return {JSX.Element} The rendered component.
20855 */
20856
20857 function PostSwitchToDraftButton() {
20858 external_wp_deprecated_default()('wp.editor.PostSwitchToDraftButton', {
20859 since: '6.7',
20860 version: '6.9'
20861 });
20862 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
20863 const {
20864 editPost,
20865 savePost
20866 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
20867 const {
20868 isSaving,
20869 isPublished,
20870 isScheduled
20871 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20872 const {
20873 isSavingPost,
20874 isCurrentPostPublished,
20875 isCurrentPostScheduled
20876 } = select(store_store);
20877 return {
20878 isSaving: isSavingPost(),
20879 isPublished: isCurrentPostPublished(),
20880 isScheduled: isCurrentPostScheduled()
20881 };
20882 }, []);
20883 const isDisabled = isSaving || !isPublished && !isScheduled;
20884 let alertMessage;
20885 let confirmButtonText;
20886 if (isPublished) {
20887 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unpublish this post?');
20888 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unpublish');
20889 } else if (isScheduled) {
20890 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unschedule this post?');
20891 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unschedule');
20892 }
20893 const handleConfirm = () => {
20894 setShowConfirmDialog(false);
20895 editPost({
20896 status: 'draft'
20897 });
20898 savePost();
20899 };
20900 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
20901 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
20902 __next40pxDefaultSize: true,
20903 className: "editor-post-switch-to-draft",
20904 onClick: () => {
20905 if (!isDisabled) {
20906 setShowConfirmDialog(true);
20907 }
20908 },
20909 "aria-disabled": isDisabled,
20910 variant: "secondary",
20911 style: {
20912 flexGrow: '1',
20913 justifyContent: 'center'
20914 },
20915 children: (0,external_wp_i18n_namespaceObject.__)('Switch to draft')
20916 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
20917 isOpen: showConfirmDialog,
20918 onConfirm: handleConfirm,
20919 onCancel: () => setShowConfirmDialog(false),
20920 confirmButtonText: confirmButtonText,
20921 children: alertMessage
20922 })]
20923 });
20924 }
20925
20926 ;// ./packages/editor/build-module/components/post-sync-status/index.js
20927 /**
20928 * WordPress dependencies
20929 */
20930
20931
20932
20933 /**
20934 * Internal dependencies
20935 */
20936
20937
20938
20939 /**
20940 * Renders the sync status of a post.
20941 *
20942 * @return {JSX.Element|null} The rendered sync status component.
20943 */
20944
20945 function PostSyncStatus() {
20946 const {
20947 syncStatus,
20948 postType
20949 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20950 const {
20951 getEditedPostAttribute
20952 } = select(store_store);
20953 const meta = getEditedPostAttribute('meta');
20954
20955 // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
20956 const currentSyncStatus = meta?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status');
20957 return {
20958 syncStatus: currentSyncStatus,
20959 postType: getEditedPostAttribute('type')
20960 };
20961 });
20962 if (postType !== 'wp_block') {
20963 return null;
20964 }
20965 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
20966 label: (0,external_wp_i18n_namespaceObject.__)('Sync status'),
20967 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20968 className: "editor-post-sync-status__value",
20969 children: syncStatus === 'unsynced' ? (0,external_wp_i18n_namespaceObject._x)('Not synced', 'pattern (singular)') : (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)')
20970 })
20971 });
20972 }
20973
20974 ;// ./packages/editor/build-module/components/post-taxonomies/index.js
20975 /**
20976 * WordPress dependencies
20977 */
20978
20979
20980
20981
20982 /**
20983 * Internal dependencies
20984 */
20985
20986
20987
20988
20989 const post_taxonomies_identity = x => x;
20990 function PostTaxonomies({
20991 taxonomyWrapper = post_taxonomies_identity
20992 }) {
20993 const {
20994 postType,
20995 taxonomies
20996 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20997 return {
20998 postType: select(store_store).getCurrentPostType(),
20999 taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({
21000 per_page: -1
21001 })
21002 };
21003 }, []);
21004 const visibleTaxonomies = (taxonomies !== null && taxonomies !== void 0 ? taxonomies : []).filter(taxonomy =>
21005 // In some circumstances .visibility can end up as undefined so optional chaining operator required.
21006 // https://github.com/WordPress/gutenberg/issues/40326
21007 taxonomy.types.includes(postType) && taxonomy.visibility?.show_ui);
21008 return visibleTaxonomies.map(taxonomy => {
21009 const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector : flat_term_selector;
21010 const taxonomyComponentProps = {
21011 slug: taxonomy.slug,
21012 ...(taxonomy.hierarchical ? {} : {
21013 __nextHasNoMarginBottom: true
21014 })
21015 };
21016 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
21017 children: taxonomyWrapper(/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyComponent, {
21018 ...taxonomyComponentProps
21019 }), taxonomy)
21020 }, `taxonomy-${taxonomy.slug}`);
21021 });
21022 }
21023
21024 /**
21025 * Renders the taxonomies associated with a post.
21026 *
21027 * @param {Object} props The component props.
21028 * @param {Function} props.taxonomyWrapper The wrapper function for each taxonomy component.
21029 *
21030 * @return {Array} An array of JSX elements representing the visible taxonomies.
21031 */
21032 /* harmony default export */ const post_taxonomies = (PostTaxonomies);
21033
21034 ;// ./packages/editor/build-module/components/post-taxonomies/check.js
21035 /**
21036 * WordPress dependencies
21037 */
21038
21039
21040
21041 /**
21042 * Internal dependencies
21043 */
21044
21045
21046 /**
21047 * Renders the children components only if the current post type has taxonomies.
21048 *
21049 * @param {Object} props The component props.
21050 * @param {Element} props.children The children components to render.
21051 *
21052 * @return {Component|null} The rendered children components or null if the current post type has no taxonomies.
21053 */
21054 function PostTaxonomiesCheck({
21055 children
21056 }) {
21057 const hasTaxonomies = (0,external_wp_data_namespaceObject.useSelect)(select => {
21058 const postType = select(store_store).getCurrentPostType();
21059 const taxonomies = select(external_wp_coreData_namespaceObject.store).getTaxonomies({
21060 per_page: -1
21061 });
21062 return taxonomies?.some(taxonomy => taxonomy.types.includes(postType));
21063 }, []);
21064 if (!hasTaxonomies) {
21065 return null;
21066 }
21067 return children;
21068 }
21069
21070 ;// ./packages/editor/build-module/components/post-taxonomies/panel.js
21071 /**
21072 * WordPress dependencies
21073 */
21074
21075
21076
21077 /**
21078 * Internal dependencies
21079 */
21080
21081
21082
21083
21084 function TaxonomyPanel({
21085 taxonomy,
21086 children
21087 }) {
21088 const slug = taxonomy?.slug;
21089 const panelName = slug ? `taxonomy-panel-${slug}` : '';
21090 const {
21091 isEnabled,
21092 isOpened
21093 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21094 const {
21095 isEditorPanelEnabled,
21096 isEditorPanelOpened
21097 } = select(store_store);
21098 return {
21099 isEnabled: slug ? isEditorPanelEnabled(panelName) : false,
21100 isOpened: slug ? isEditorPanelOpened(panelName) : false
21101 };
21102 }, [panelName, slug]);
21103 const {
21104 toggleEditorPanelOpened
21105 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
21106 if (!isEnabled) {
21107 return null;
21108 }
21109 const taxonomyMenuName = taxonomy?.labels?.menu_name;
21110 if (!taxonomyMenuName) {
21111 return null;
21112 }
21113 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
21114 title: taxonomyMenuName,
21115 opened: isOpened,
21116 onToggle: () => toggleEditorPanelOpened(panelName),
21117 children: children
21118 });
21119 }
21120 function panel_PostTaxonomies() {
21121 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTaxonomiesCheck, {
21122 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
21123 taxonomyWrapper: (content, taxonomy) => {
21124 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyPanel, {
21125 taxonomy: taxonomy,
21126 children: content
21127 });
21128 }
21129 })
21130 });
21131 }
21132
21133 /**
21134 * Renders a panel for a specific taxonomy.
21135 *
21136 * @param {Object} props The component props.
21137 * @param {Object} props.taxonomy The taxonomy object.
21138 * @param {Element} props.children The child components.
21139 *
21140 * @return {Component} The rendered taxonomy panel.
21141 */
21142 /* harmony default export */ const post_taxonomies_panel = (panel_PostTaxonomies);
21143
21144 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
21145 var lib = __webpack_require__(4132);
21146 ;// ./packages/editor/build-module/components/post-text-editor/index.js
21147 /**
21148 * External dependencies
21149 */
21150
21151
21152 /**
21153 * WordPress dependencies
21154 */
21155
21156
21157
21158
21159
21160
21161
21162
21163 /**
21164 * Internal dependencies
21165 */
21166
21167
21168 /**
21169 * Displays the Post Text Editor along with content in Visual and Text mode.
21170 *
21171 * @return {JSX.Element|null} The rendered PostTextEditor component.
21172 */
21173
21174 function PostTextEditor() {
21175 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostTextEditor);
21176 const {
21177 content,
21178 blocks,
21179 type,
21180 id
21181 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21182 const {
21183 getEditedEntityRecord
21184 } = select(external_wp_coreData_namespaceObject.store);
21185 const {
21186 getCurrentPostType,
21187 getCurrentPostId
21188 } = select(store_store);
21189 const _type = getCurrentPostType();
21190 const _id = getCurrentPostId();
21191 const editedRecord = getEditedEntityRecord('postType', _type, _id);
21192 return {
21193 content: editedRecord?.content,
21194 blocks: editedRecord?.blocks,
21195 type: _type,
21196 id: _id
21197 };
21198 }, []);
21199 const {
21200 editEntityRecord
21201 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
21202 // Replicates the logic found in getEditedPostContent().
21203 const value = (0,external_wp_element_namespaceObject.useMemo)(() => {
21204 if (content instanceof Function) {
21205 return content({
21206 blocks
21207 });
21208 } else if (blocks) {
21209 // If we have parsed blocks already, they should be our source of truth.
21210 // Parsing applies block deprecations and legacy block conversions that
21211 // unparsed content will not have.
21212 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocks);
21213 }
21214 return content;
21215 }, [content, blocks]);
21216 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21217 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
21218 as: "label",
21219 htmlFor: `post-content-${instanceId}`,
21220 children: (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')
21221 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(lib/* default */.A, {
21222 autoComplete: "off",
21223 dir: "auto",
21224 value: value,
21225 onChange: event => {
21226 editEntityRecord('postType', type, id, {
21227 content: event.target.value,
21228 blocks: undefined,
21229 selection: undefined
21230 });
21231 },
21232 className: "editor-post-text-editor",
21233 id: `post-content-${instanceId}`,
21234 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
21235 })]
21236 });
21237 }
21238
21239 ;// external ["wp","dom"]
21240 const external_wp_dom_namespaceObject = window["wp"]["dom"];
21241 ;// ./packages/editor/build-module/components/post-title/constants.js
21242 const DEFAULT_CLASSNAMES = 'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text';
21243 const REGEXP_NEWLINES = /[\r\n]+/g;
21244
21245 ;// ./packages/editor/build-module/components/post-title/use-post-title-focus.js
21246 /**
21247 * WordPress dependencies
21248 */
21249
21250
21251
21252 /**
21253 * Internal dependencies
21254 */
21255
21256
21257 /**
21258 * Custom hook that manages the focus behavior of the post title input field.
21259 *
21260 * @param {Element} forwardedRef - The forwarded ref for the input field.
21261 *
21262 * @return {Object} - The ref object.
21263 */
21264 function usePostTitleFocus(forwardedRef) {
21265 const ref = (0,external_wp_element_namespaceObject.useRef)();
21266 const {
21267 isCleanNewPost
21268 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21269 const {
21270 isCleanNewPost: _isCleanNewPost
21271 } = select(store_store);
21272 return {
21273 isCleanNewPost: _isCleanNewPost()
21274 };
21275 }, []);
21276 (0,external_wp_element_namespaceObject.useImperativeHandle)(forwardedRef, () => ({
21277 focus: () => {
21278 ref?.current?.focus();
21279 }
21280 }));
21281 (0,external_wp_element_namespaceObject.useEffect)(() => {
21282 if (!ref.current) {
21283 return;
21284 }
21285 const {
21286 defaultView
21287 } = ref.current.ownerDocument;
21288 const {
21289 name,
21290 parent
21291 } = defaultView;
21292 const ownerDocument = name === 'editor-canvas' ? parent.document : defaultView.document;
21293 const {
21294 activeElement,
21295 body
21296 } = ownerDocument;
21297
21298 // Only autofocus the title when the post is entirely empty. This should
21299 // only happen for a new post, which means we focus the title on new
21300 // post so the author can start typing right away, without needing to
21301 // click anything.
21302 if (isCleanNewPost && (!activeElement || body === activeElement)) {
21303 ref.current.focus();
21304 }
21305 }, [isCleanNewPost]);
21306 return {
21307 ref
21308 };
21309 }
21310
21311 ;// ./packages/editor/build-module/components/post-title/use-post-title.js
21312 /**
21313 * WordPress dependencies
21314 */
21315
21316 /**
21317 * Internal dependencies
21318 */
21319
21320
21321 /**
21322 * Custom hook for managing the post title in the editor.
21323 *
21324 * @return {Object} An object containing the current title and a function to update the title.
21325 */
21326 function usePostTitle() {
21327 const {
21328 editPost
21329 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
21330 const {
21331 title
21332 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21333 const {
21334 getEditedPostAttribute
21335 } = select(store_store);
21336 return {
21337 title: getEditedPostAttribute('title')
21338 };
21339 }, []);
21340 function updateTitle(newTitle) {
21341 editPost({
21342 title: newTitle
21343 });
21344 }
21345 return {
21346 title,
21347 setTitle: updateTitle
21348 };
21349 }
21350
21351 ;// ./packages/editor/build-module/components/post-title/index.js
21352 /**
21353 * External dependencies
21354 */
21355
21356 /**
21357 * WordPress dependencies
21358 */
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370 /**
21371 * Internal dependencies
21372 */
21373
21374
21375
21376
21377
21378 function PostTitle(_, forwardedRef) {
21379 const {
21380 placeholder
21381 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21382 const {
21383 getSettings
21384 } = select(external_wp_blockEditor_namespaceObject.store);
21385 const {
21386 titlePlaceholder
21387 } = getSettings();
21388 return {
21389 placeholder: titlePlaceholder
21390 };
21391 }, []);
21392 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
21393 const {
21394 ref: focusRef
21395 } = usePostTitleFocus(forwardedRef);
21396 const {
21397 title,
21398 setTitle: onUpdate
21399 } = usePostTitle();
21400 const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)({});
21401 const {
21402 clearSelectedBlock,
21403 insertBlocks,
21404 insertDefaultBlock
21405 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
21406 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
21407 const {
21408 value,
21409 onChange,
21410 ref: richTextRef
21411 } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({
21412 value: title,
21413 onChange(newValue) {
21414 onUpdate(newValue.replace(REGEXP_NEWLINES, ' '));
21415 },
21416 placeholder: decodedPlaceholder,
21417 selectionStart: selection.start,
21418 selectionEnd: selection.end,
21419 onSelectionChange(newStart, newEnd) {
21420 setSelection(sel => {
21421 const {
21422 start,
21423 end
21424 } = sel;
21425 if (start === newStart && end === newEnd) {
21426 return sel;
21427 }
21428 return {
21429 start: newStart,
21430 end: newEnd
21431 };
21432 });
21433 },
21434 __unstableDisableFormats: false
21435 });
21436 function onInsertBlockAfter(blocks) {
21437 insertBlocks(blocks, 0);
21438 }
21439 function onSelect() {
21440 setIsSelected(true);
21441 clearSelectedBlock();
21442 }
21443 function onUnselect() {
21444 setIsSelected(false);
21445 setSelection({});
21446 }
21447 function onEnterPress() {
21448 insertDefaultBlock(undefined, undefined, 0);
21449 }
21450 function onKeyDown(event) {
21451 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
21452 event.preventDefault();
21453 onEnterPress();
21454 }
21455 }
21456 function onPaste(event) {
21457 const clipboardData = event.clipboardData;
21458 let plainText = '';
21459 let html = '';
21460 try {
21461 plainText = clipboardData.getData('text/plain');
21462 html = clipboardData.getData('text/html');
21463 } catch (error) {
21464 // Some browsers like UC Browser paste plain text by default and
21465 // don't support clipboardData at all, so allow default
21466 // behaviour.
21467 return;
21468 }
21469
21470 // Allows us to ask for this information when we get a report.
21471 window.console.log('Received HTML:\n\n', html);
21472 window.console.log('Received plain text:\n\n', plainText);
21473 const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
21474 HTML: html,
21475 plainText
21476 });
21477 event.preventDefault();
21478 if (!content.length) {
21479 return;
21480 }
21481 if (typeof content !== 'string') {
21482 const [firstBlock] = content;
21483 if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) {
21484 // Strip HTML to avoid unwanted HTML being added to the title.
21485 // In the majority of cases it is assumed that HTML in the title
21486 // is undesirable.
21487 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(firstBlock.attributes.content);
21488 onUpdate(contentNoHTML);
21489 onInsertBlockAfter(content.slice(1));
21490 } else {
21491 onInsertBlockAfter(content);
21492 }
21493 } else {
21494 // Strip HTML to avoid unwanted HTML being added to the title.
21495 // In the majority of cases it is assumed that HTML in the title
21496 // is undesirable.
21497 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(content);
21498 onChange((0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.create)({
21499 html: contentNoHTML
21500 })));
21501 }
21502 }
21503
21504 // The wp-block className is important for editor styles.
21505 // This same block is used in both the visual and the code editor.
21506 const className = dist_clsx(DEFAULT_CLASSNAMES, {
21507 'is-selected': isSelected
21508 });
21509 return /*#__PURE__*/ /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
21510 supportKeys: "title",
21511 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
21512 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([richTextRef, focusRef]),
21513 contentEditable: true,
21514 className: className,
21515 "aria-label": decodedPlaceholder,
21516 role: "textbox",
21517 "aria-multiline": "true",
21518 onFocus: onSelect,
21519 onBlur: onUnselect,
21520 onKeyDown: onKeyDown,
21521 onPaste: onPaste
21522 })
21523 })
21524 /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */;
21525 }
21526
21527 /**
21528 * Renders the `PostTitle` component.
21529 *
21530 * @param {Object} _ Unused parameter.
21531 * @param {Element} forwardedRef Forwarded ref for the component.
21532 *
21533 * @return {Component} The rendered PostTitle component.
21534 */
21535 /* harmony default export */ const post_title = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitle));
21536
21537 ;// ./packages/editor/build-module/components/post-title/post-title-raw.js
21538 /**
21539 * External dependencies
21540 */
21541
21542
21543 /**
21544 * WordPress dependencies
21545 */
21546
21547
21548
21549
21550
21551
21552
21553 /**
21554 * Internal dependencies
21555 */
21556
21557
21558
21559
21560 /**
21561 * Renders a raw post title input field.
21562 *
21563 * @param {Object} _ Unused parameter.
21564 * @param {Element} forwardedRef Reference to the component's DOM node.
21565 *
21566 * @return {Component} The rendered component.
21567 */
21568
21569 function PostTitleRaw(_, forwardedRef) {
21570 const {
21571 placeholder
21572 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21573 const {
21574 getSettings
21575 } = select(external_wp_blockEditor_namespaceObject.store);
21576 const {
21577 titlePlaceholder
21578 } = getSettings();
21579 return {
21580 placeholder: titlePlaceholder
21581 };
21582 }, []);
21583 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
21584 const {
21585 title,
21586 setTitle: onUpdate
21587 } = usePostTitle();
21588 const {
21589 ref: focusRef
21590 } = usePostTitleFocus(forwardedRef);
21591 function onChange(value) {
21592 onUpdate(value.replace(REGEXP_NEWLINES, ' '));
21593 }
21594 function onSelect() {
21595 setIsSelected(true);
21596 }
21597 function onUnselect() {
21598 setIsSelected(false);
21599 }
21600
21601 // The wp-block className is important for editor styles.
21602 // This same block is used in both the visual and the code editor.
21603 const className = dist_clsx(DEFAULT_CLASSNAMES, {
21604 'is-selected': isSelected,
21605 'is-raw-text': true
21606 });
21607 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
21608 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
21609 ref: focusRef,
21610 value: title,
21611 onChange: onChange,
21612 onFocus: onSelect,
21613 onBlur: onUnselect,
21614 label: placeholder,
21615 className: className,
21616 placeholder: decodedPlaceholder,
21617 hideLabelFromVision: true,
21618 autoComplete: "off",
21619 dir: "auto",
21620 rows: 1,
21621 __nextHasNoMarginBottom: true
21622 });
21623 }
21624 /* harmony default export */ const post_title_raw = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitleRaw));
21625
21626 ;// ./packages/editor/build-module/components/post-trash/check.js
21627 /**
21628 * WordPress dependencies
21629 */
21630
21631
21632
21633 /**
21634 * Internal dependencies
21635 */
21636
21637
21638
21639 /**
21640 * Wrapper component that renders its children only if the post can trashed.
21641 *
21642 * @param {Object} props - The component props.
21643 * @param {Element} props.children - The child components to render.
21644 *
21645 * @return {Component|null} The rendered child components or null if the post can not trashed.
21646 */
21647 function PostTrashCheck({
21648 children
21649 }) {
21650 const {
21651 canTrashPost
21652 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21653 const {
21654 isEditedPostNew,
21655 getCurrentPostId,
21656 getCurrentPostType
21657 } = select(store_store);
21658 const {
21659 canUser
21660 } = select(external_wp_coreData_namespaceObject.store);
21661 const postType = getCurrentPostType();
21662 const postId = getCurrentPostId();
21663 const isNew = isEditedPostNew();
21664 const canUserDelete = !!postId ? canUser('delete', {
21665 kind: 'postType',
21666 name: postType,
21667 id: postId
21668 }) : false;
21669 return {
21670 canTrashPost: (!isNew || postId) && canUserDelete && !GLOBAL_POST_TYPES.includes(postType)
21671 };
21672 }, []);
21673 if (!canTrashPost) {
21674 return null;
21675 }
21676 return children;
21677 }
21678
21679 ;// ./packages/editor/build-module/components/post-trash/index.js
21680 /**
21681 * WordPress dependencies
21682 */
21683
21684
21685
21686
21687
21688 /**
21689 * Internal dependencies
21690 */
21691
21692
21693
21694 /**
21695 * Displays the Post Trash Button and Confirm Dialog in the Editor.
21696 *
21697 * @param {?{onActionPerformed: Object}} An object containing the onActionPerformed function.
21698 * @return {JSX.Element|null} The rendered PostTrash component.
21699 */
21700
21701 function PostTrash({
21702 onActionPerformed
21703 }) {
21704 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
21705 const {
21706 isNew,
21707 isDeleting,
21708 postId,
21709 title
21710 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21711 const store = select(store_store);
21712 return {
21713 isNew: store.isEditedPostNew(),
21714 isDeleting: store.isDeletingPost(),
21715 postId: store.getCurrentPostId(),
21716 title: store.getCurrentPostAttribute('title')
21717 };
21718 }, []);
21719 const {
21720 trashPost
21721 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
21722 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
21723 if (isNew || !postId) {
21724 return null;
21725 }
21726 const handleConfirm = async () => {
21727 setShowConfirmDialog(false);
21728 await trashPost();
21729 const item = await registry.resolveSelect(store_store).getCurrentPost();
21730 // After the post is trashed, we want to trigger the onActionPerformed callback, so the user is redirect
21731 // to the post view depending on if the user is on post editor or site editor.
21732 onActionPerformed?.('move-to-trash', [item]);
21733 };
21734 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PostTrashCheck, {
21735 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
21736 __next40pxDefaultSize: true,
21737 className: "editor-post-trash",
21738 isDestructive: true,
21739 variant: "secondary",
21740 isBusy: isDeleting,
21741 "aria-disabled": isDeleting,
21742 onClick: isDeleting ? undefined : () => setShowConfirmDialog(true),
21743 children: (0,external_wp_i18n_namespaceObject.__)('Move to trash')
21744 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
21745 isOpen: showConfirmDialog,
21746 onConfirm: handleConfirm,
21747 onCancel: () => setShowConfirmDialog(false),
21748 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Move to trash'),
21749 size: "small",
21750 children: (0,external_wp_i18n_namespaceObject.sprintf)(
21751 // translators: %s: The item's title.
21752 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move "%s" to the trash?'), title)
21753 })]
21754 });
21755 }
21756
21757 ;// ./packages/icons/build-module/library/copy-small.js
21758 /**
21759 * WordPress dependencies
21760 */
21761
21762
21763 const copySmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
21764 xmlns: "http://www.w3.org/2000/svg",
21765 viewBox: "0 0 24 24",
21766 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
21767 fillRule: "evenodd",
21768 clipRule: "evenodd",
21769 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"
21770 })
21771 });
21772 /* harmony default export */ const copy_small = (copySmall);
21773
21774 ;// ./packages/editor/build-module/components/post-url/index.js
21775 /**
21776 * WordPress dependencies
21777 */
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789 /**
21790 * Internal dependencies
21791 */
21792
21793
21794 /**
21795 * Renders the `PostURL` component.
21796 *
21797 * @example
21798 * ```jsx
21799 * <PostURL />
21800 * ```
21801 *
21802 * @param {Function} onClose Callback function to be executed when the popover is closed.
21803 *
21804 * @return {Component} The rendered PostURL component.
21805 */
21806
21807 function PostURL({
21808 onClose
21809 }) {
21810 const {
21811 isEditable,
21812 postSlug,
21813 postLink,
21814 permalinkPrefix,
21815 permalinkSuffix,
21816 permalink
21817 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21818 var _post$_links$wpActio;
21819 const post = select(store_store).getCurrentPost();
21820 const postTypeSlug = select(store_store).getCurrentPostType();
21821 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
21822 const permalinkParts = select(store_store).getPermalinkParts();
21823 const hasPublishAction = (_post$_links$wpActio = post?._links?.['wp:action-publish']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false;
21824 return {
21825 isEditable: select(store_store).isPermalinkEditable() && hasPublishAction,
21826 postSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug()),
21827 viewPostLabel: postType?.labels.view_item,
21828 postLink: post.link,
21829 permalinkPrefix: permalinkParts?.prefix,
21830 permalinkSuffix: permalinkParts?.suffix,
21831 permalink: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getPermalink())
21832 };
21833 }, []);
21834 const {
21835 editPost
21836 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
21837 const {
21838 createNotice
21839 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
21840 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
21841 const copyButtonRef = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(permalink, () => {
21842 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('Copied Permalink to clipboard.'), {
21843 isDismissible: true,
21844 type: 'snackbar'
21845 });
21846 });
21847 const postUrlSlugDescriptionId = 'editor-post-url__slug-description-' + (0,external_wp_compose_namespaceObject.useInstanceId)(PostURL);
21848 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21849 className: "editor-post-url",
21850 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
21851 title: (0,external_wp_i18n_namespaceObject.__)('Slug'),
21852 onClose: onClose
21853 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
21854 spacing: 3,
21855 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
21856 className: "editor-post-url__intro",
21857 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>'), {
21858 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21859 id: postUrlSlugDescriptionId
21860 }),
21861 a: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
21862 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink')
21863 })
21864 })
21865 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21866 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21867 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
21868 __next40pxDefaultSize: true,
21869 prefix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControlPrefixWrapper, {
21870 children: "/"
21871 }),
21872 suffix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControlSuffixWrapper, {
21873 variant: "control",
21874 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
21875 icon: copy_small,
21876 ref: copyButtonRef,
21877 size: "small",
21878 label: "Copy"
21879 })
21880 }),
21881 label: (0,external_wp_i18n_namespaceObject.__)('Slug'),
21882 hideLabelFromVision: true,
21883 value: forceEmptyField ? '' : postSlug,
21884 autoComplete: "off",
21885 spellCheck: "false",
21886 type: "text",
21887 className: "editor-post-url__input",
21888 onChange: newValue => {
21889 editPost({
21890 slug: newValue
21891 });
21892 // When we delete the field the permalink gets
21893 // reverted to the original value.
21894 // The forceEmptyField logic allows the user to have
21895 // the field temporarily empty while typing.
21896 if (!newValue) {
21897 if (!forceEmptyField) {
21898 setForceEmptyField(true);
21899 }
21900 return;
21901 }
21902 if (forceEmptyField) {
21903 setForceEmptyField(false);
21904 }
21905 },
21906 onBlur: event => {
21907 editPost({
21908 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value)
21909 });
21910 if (forceEmptyField) {
21911 setForceEmptyField(false);
21912 }
21913 },
21914 "aria-describedby": postUrlSlugDescriptionId
21915 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("p", {
21916 className: "editor-post-url__permalink",
21917 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21918 className: "editor-post-url__permalink-visual-label",
21919 children: (0,external_wp_i18n_namespaceObject.__)('Permalink:')
21920 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.ExternalLink, {
21921 className: "editor-post-url__link",
21922 href: postLink,
21923 target: "_blank",
21924 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21925 className: "editor-post-url__link-prefix",
21926 children: permalinkPrefix
21927 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21928 className: "editor-post-url__link-slug",
21929 children: postSlug
21930 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21931 className: "editor-post-url__link-suffix",
21932 children: permalinkSuffix
21933 })]
21934 })]
21935 })]
21936 }), !isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
21937 className: "editor-post-url__link",
21938 href: postLink,
21939 target: "_blank",
21940 children: postLink
21941 })]
21942 })]
21943 })]
21944 });
21945 }
21946
21947 ;// ./packages/editor/build-module/components/post-url/check.js
21948 /**
21949 * WordPress dependencies
21950 */
21951
21952
21953
21954 /**
21955 * Internal dependencies
21956 */
21957
21958
21959 /**
21960 * Check if the post URL is valid and visible.
21961 *
21962 * @param {Object} props The component props.
21963 * @param {Element} props.children The child components.
21964 *
21965 * @return {Component|null} The child components if the post URL is valid and visible, otherwise null.
21966 */
21967 function PostURLCheck({
21968 children
21969 }) {
21970 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
21971 const postTypeSlug = select(store_store).getCurrentPostType();
21972 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
21973 if (!postType?.viewable) {
21974 return false;
21975 }
21976 const post = select(store_store).getCurrentPost();
21977 if (!post.link) {
21978 return false;
21979 }
21980 const permalinkParts = select(store_store).getPermalinkParts();
21981 if (!permalinkParts) {
21982 return false;
21983 }
21984 return true;
21985 }, []);
21986 if (!isVisible) {
21987 return null;
21988 }
21989 return children;
21990 }
21991
21992 ;// ./packages/editor/build-module/components/post-url/label.js
21993 /**
21994 * WordPress dependencies
21995 */
21996
21997
21998
21999 /**
22000 * Internal dependencies
22001 */
22002
22003
22004 /**
22005 * Represents a label component for a post URL.
22006 *
22007 * @return {Component} The PostURLLabel component.
22008 */
22009 function PostURLLabel() {
22010 return usePostURLLabel();
22011 }
22012
22013 /**
22014 * Custom hook to get the label for the post URL.
22015 *
22016 * @return {string} The filtered and decoded post URL label.
22017 */
22018 function usePostURLLabel() {
22019 const postLink = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getPermalink(), []);
22020 return (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURIComponent)(postLink));
22021 }
22022
22023 ;// ./packages/editor/build-module/components/post-url/panel.js
22024 /**
22025 * WordPress dependencies
22026 */
22027
22028
22029
22030
22031
22032
22033
22034 /**
22035 * Internal dependencies
22036 */
22037
22038
22039
22040
22041
22042 /**
22043 * Renders the `PostURLPanel` component.
22044 *
22045 * @return {JSX.Element} The rendered PostURLPanel component.
22046 */
22047
22048 function PostURLPanel() {
22049 const {
22050 isFrontPage
22051 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22052 const {
22053 getCurrentPostId
22054 } = select(store_store);
22055 const {
22056 getEditedEntityRecord,
22057 canUser
22058 } = select(external_wp_coreData_namespaceObject.store);
22059 const siteSettings = canUser('read', {
22060 kind: 'root',
22061 name: 'site'
22062 }) ? getEditedEntityRecord('root', 'site') : undefined;
22063 const _id = getCurrentPostId();
22064 return {
22065 isFrontPage: siteSettings?.page_on_front === _id
22066 };
22067 }, []);
22068 // Use internal state instead of a ref to make sure that the component
22069 // re-renders when the popover's anchor updates.
22070 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
22071 // Memoize popoverProps to avoid returning a new object every time.
22072 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
22073 // Anchor the popover to the middle of the entire row so that it doesn't
22074 // move around when the label changes.
22075 anchor: popoverAnchor,
22076 placement: 'left-start',
22077 offset: 36,
22078 shift: true
22079 }), [popoverAnchor]);
22080 const label = isFrontPage ? (0,external_wp_i18n_namespaceObject.__)('Link') : (0,external_wp_i18n_namespaceObject.__)('Slug');
22081 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLCheck, {
22082 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(post_panel_row, {
22083 label: label,
22084 ref: setPopoverAnchor,
22085 children: [!isFrontPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
22086 popoverProps: popoverProps,
22087 className: "editor-post-url__panel-dropdown",
22088 contentClassName: "editor-post-url__panel-dialog",
22089 focusOnMount: true,
22090 renderToggle: ({
22091 isOpen,
22092 onToggle
22093 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLToggle, {
22094 isOpen: isOpen,
22095 onClick: onToggle
22096 }),
22097 renderContent: ({
22098 onClose
22099 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURL, {
22100 onClose: onClose
22101 })
22102 }), isFrontPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(FrontPageLink, {})]
22103 })
22104 });
22105 }
22106 function PostURLToggle({
22107 isOpen,
22108 onClick
22109 }) {
22110 const {
22111 slug
22112 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22113 return {
22114 slug: select(store_store).getEditedPostSlug()
22115 };
22116 }, []);
22117 const decodedSlug = (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(slug);
22118 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22119 size: "compact",
22120 className: "editor-post-url__panel-toggle",
22121 variant: "tertiary",
22122 "aria-expanded": isOpen,
22123 "aria-label":
22124 // translators: %s: Current post link.
22125 (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change link: %s'), decodedSlug),
22126 onClick: onClick,
22127 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22128 children: decodedSlug
22129 })
22130 });
22131 }
22132 function FrontPageLink() {
22133 const {
22134 postLink
22135 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22136 const {
22137 getCurrentPost
22138 } = select(store_store);
22139 return {
22140 postLink: getCurrentPost()?.link
22141 };
22142 }, []);
22143 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
22144 className: "editor-post-url__front-page-link",
22145 href: postLink,
22146 target: "_blank",
22147 children: postLink
22148 });
22149 }
22150
22151 ;// ./packages/editor/build-module/components/post-visibility/check.js
22152 /**
22153 * WordPress dependencies
22154 */
22155
22156
22157 /**
22158 * Internal dependencies
22159 */
22160
22161
22162 /**
22163 * Determines if the current post can be edited (published)
22164 * and passes this information to the provided render function.
22165 *
22166 * @param {Object} props The component props.
22167 * @param {Function} props.render Function to render the component.
22168 * Receives an object with a `canEdit` property.
22169 * @return {JSX.Element} The rendered component.
22170 */
22171 function PostVisibilityCheck({
22172 render
22173 }) {
22174 const canEdit = (0,external_wp_data_namespaceObject.useSelect)(select => {
22175 var _select$getCurrentPos;
22176 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
22177 });
22178 return render({
22179 canEdit
22180 });
22181 }
22182
22183 ;// ./packages/icons/build-module/library/info.js
22184 /**
22185 * WordPress dependencies
22186 */
22187
22188
22189 const info = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22190 xmlns: "http://www.w3.org/2000/svg",
22191 viewBox: "0 0 24 24",
22192 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22193 d: "M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"
22194 })
22195 });
22196 /* harmony default export */ const library_info = (info);
22197
22198 ;// external ["wp","wordcount"]
22199 const external_wp_wordcount_namespaceObject = window["wp"]["wordcount"];
22200 ;// ./packages/editor/build-module/components/word-count/index.js
22201 /**
22202 * WordPress dependencies
22203 */
22204
22205
22206
22207
22208 /**
22209 * Internal dependencies
22210 */
22211
22212
22213 /**
22214 * Renders the word count of the post content.
22215 *
22216 * @return {JSX.Element|null} The rendered WordCount component.
22217 */
22218
22219 function WordCount() {
22220 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
22221
22222 /*
22223 * translators: If your word count is based on single characters (e.g. East Asian characters),
22224 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
22225 * Do not translate into your own language.
22226 */
22227 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
22228 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
22229 className: "word-count",
22230 children: (0,external_wp_wordcount_namespaceObject.count)(content, wordCountType)
22231 });
22232 }
22233
22234 ;// ./packages/editor/build-module/components/time-to-read/index.js
22235 /**
22236 * WordPress dependencies
22237 */
22238
22239
22240
22241
22242
22243 /**
22244 * Internal dependencies
22245 */
22246
22247
22248 /**
22249 * Average reading rate - based on average taken from
22250 * https://irisreading.com/average-reading-speed-in-various-languages/
22251 * (Characters/minute used for Chinese rather than words).
22252 *
22253 * @type {number} A rough estimate of the average reading rate across multiple languages.
22254 */
22255
22256 const AVERAGE_READING_RATE = 189;
22257
22258 /**
22259 * Component for showing Time To Read in Content.
22260 *
22261 * @return {JSX.Element} The rendered TimeToRead component.
22262 */
22263 function TimeToRead() {
22264 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
22265
22266 /*
22267 * translators: If your word count is based on single characters (e.g. East Asian characters),
22268 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
22269 * Do not translate into your own language.
22270 */
22271 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
22272 const minutesToRead = Math.round((0,external_wp_wordcount_namespaceObject.count)(content, wordCountType) / AVERAGE_READING_RATE);
22273 const minutesToReadString = minutesToRead === 0 ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('<span>< 1</span> minute'), {
22274 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
22275 }) : (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: the number of minutes to read the post. */
22276 (0,external_wp_i18n_namespaceObject._n)('<span>%s</span> minute', '<span>%s</span> minutes', minutesToRead), minutesToRead), {
22277 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
22278 });
22279 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
22280 className: "time-to-read",
22281 children: minutesToReadString
22282 });
22283 }
22284
22285 ;// ./packages/editor/build-module/components/character-count/index.js
22286 /**
22287 * WordPress dependencies
22288 */
22289
22290
22291
22292 /**
22293 * Internal dependencies
22294 */
22295
22296
22297 /**
22298 * Renders the character count of the post content.
22299 *
22300 * @return {number} The character count.
22301 */
22302 function CharacterCount() {
22303 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
22304 return (0,external_wp_wordcount_namespaceObject.count)(content, 'characters_including_spaces');
22305 }
22306
22307 ;// ./packages/editor/build-module/components/table-of-contents/panel.js
22308 /**
22309 * WordPress dependencies
22310 */
22311
22312
22313
22314
22315 /**
22316 * Internal dependencies
22317 */
22318
22319
22320
22321
22322
22323 function TableOfContentsPanel({
22324 hasOutlineItemsDisabled,
22325 onRequestClose
22326 }) {
22327 const {
22328 headingCount,
22329 paragraphCount,
22330 numberOfBlocks
22331 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22332 const {
22333 getGlobalBlockCount
22334 } = select(external_wp_blockEditor_namespaceObject.store);
22335 return {
22336 headingCount: getGlobalBlockCount('core/heading'),
22337 paragraphCount: getGlobalBlockCount('core/paragraph'),
22338 numberOfBlocks: getGlobalBlockCount()
22339 };
22340 }, []);
22341 return (
22342 /*#__PURE__*/
22343 /*
22344 * Disable reason: The `list` ARIA role is redundant but
22345 * Safari+VoiceOver won't announce the list otherwise.
22346 */
22347 /* eslint-disable jsx-a11y/no-redundant-roles */
22348 (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22349 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22350 className: "table-of-contents__wrapper",
22351 role: "note",
22352 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document Statistics'),
22353 tabIndex: "0",
22354 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
22355 role: "list",
22356 className: "table-of-contents__counts",
22357 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
22358 className: "table-of-contents__count",
22359 children: [(0,external_wp_i18n_namespaceObject.__)('Words'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
22360 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
22361 className: "table-of-contents__count",
22362 children: [(0,external_wp_i18n_namespaceObject.__)('Characters'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
22363 className: "table-of-contents__number",
22364 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
22365 })]
22366 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
22367 className: "table-of-contents__count",
22368 children: [(0,external_wp_i18n_namespaceObject.__)('Time to read'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
22369 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
22370 className: "table-of-contents__count",
22371 children: [(0,external_wp_i18n_namespaceObject.__)('Headings'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
22372 className: "table-of-contents__number",
22373 children: headingCount
22374 })]
22375 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
22376 className: "table-of-contents__count",
22377 children: [(0,external_wp_i18n_namespaceObject.__)('Paragraphs'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
22378 className: "table-of-contents__number",
22379 children: paragraphCount
22380 })]
22381 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
22382 className: "table-of-contents__count",
22383 children: [(0,external_wp_i18n_namespaceObject.__)('Blocks'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
22384 className: "table-of-contents__number",
22385 children: numberOfBlocks
22386 })]
22387 })]
22388 })
22389 }), headingCount > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22390 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("hr", {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
22391 className: "table-of-contents__title",
22392 children: (0,external_wp_i18n_namespaceObject.__)('Document Outline')
22393 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {
22394 onSelect: onRequestClose,
22395 hasOutlineItemsDisabled: hasOutlineItemsDisabled
22396 })]
22397 })]
22398 })
22399 /* eslint-enable jsx-a11y/no-redundant-roles */
22400 );
22401 }
22402 /* harmony default export */ const table_of_contents_panel = (TableOfContentsPanel);
22403
22404 ;// ./packages/editor/build-module/components/table-of-contents/index.js
22405 /**
22406 * WordPress dependencies
22407 */
22408
22409
22410
22411
22412
22413
22414
22415 /**
22416 * Internal dependencies
22417 */
22418
22419
22420 function TableOfContents({
22421 hasOutlineItemsDisabled,
22422 repositionDropdown,
22423 ...props
22424 }, ref) {
22425 const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_blockEditor_namespaceObject.store).getBlockCount(), []);
22426 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
22427 popoverProps: {
22428 placement: repositionDropdown ? 'right' : 'bottom'
22429 },
22430 className: "table-of-contents",
22431 contentClassName: "table-of-contents__popover",
22432 renderToggle: ({
22433 isOpen,
22434 onToggle
22435 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22436 __next40pxDefaultSize: true,
22437 ...props,
22438 ref: ref,
22439 onClick: hasBlocks ? onToggle : undefined,
22440 icon: library_info,
22441 "aria-expanded": isOpen,
22442 "aria-haspopup": "true"
22443 /* translators: button label text should, if possible, be under 16 characters. */,
22444 label: (0,external_wp_i18n_namespaceObject.__)('Details'),
22445 tooltipPosition: "bottom",
22446 "aria-disabled": !hasBlocks
22447 }),
22448 renderContent: ({
22449 onClose
22450 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(table_of_contents_panel, {
22451 onRequestClose: onClose,
22452 hasOutlineItemsDisabled: hasOutlineItemsDisabled
22453 })
22454 });
22455 }
22456
22457 /**
22458 * Renders a table of contents component.
22459 *
22460 * @param {Object} props The component props.
22461 * @param {boolean} props.hasOutlineItemsDisabled Whether outline items are disabled.
22462 * @param {boolean} props.repositionDropdown Whether to reposition the dropdown.
22463 * @param {Element.ref} ref The component's ref.
22464 *
22465 * @return {JSX.Element} The rendered table of contents component.
22466 */
22467 /* harmony default export */ const table_of_contents = ((0,external_wp_element_namespaceObject.forwardRef)(TableOfContents));
22468
22469 ;// ./packages/editor/build-module/components/unsaved-changes-warning/index.js
22470 /**
22471 * WordPress dependencies
22472 */
22473
22474
22475
22476
22477
22478 /**
22479 * Warns the user if there are unsaved changes before leaving the editor.
22480 * Compatible with Post Editor and Site Editor.
22481 *
22482 * @return {Component} The component.
22483 */
22484 function UnsavedChangesWarning() {
22485 const {
22486 __experimentalGetDirtyEntityRecords
22487 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
22488 (0,external_wp_element_namespaceObject.useEffect)(() => {
22489 /**
22490 * Warns the user if there are unsaved changes before leaving the editor.
22491 *
22492 * @param {Event} event `beforeunload` event.
22493 *
22494 * @return {string | undefined} Warning prompt message, if unsaved changes exist.
22495 */
22496 const warnIfUnsavedChanges = event => {
22497 // We need to call the selector directly in the listener to avoid race
22498 // conditions with `BrowserURL` where `componentDidUpdate` gets the
22499 // new value of `isEditedPostDirty` before this component does,
22500 // causing this component to incorrectly think a trashed post is still dirty.
22501 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
22502 if (dirtyEntityRecords.length > 0) {
22503 event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
22504 return event.returnValue;
22505 }
22506 };
22507 window.addEventListener('beforeunload', warnIfUnsavedChanges);
22508 return () => {
22509 window.removeEventListener('beforeunload', warnIfUnsavedChanges);
22510 };
22511 }, [__experimentalGetDirtyEntityRecords]);
22512 return null;
22513 }
22514
22515 ;// ./packages/editor/build-module/components/provider/with-registry-provider.js
22516 /**
22517 * WordPress dependencies
22518 */
22519
22520
22521
22522
22523
22524 /**
22525 * Internal dependencies
22526 */
22527
22528
22529 function getSubRegistry(subRegistries, registry, useSubRegistry) {
22530 if (!useSubRegistry) {
22531 return registry;
22532 }
22533 let subRegistry = subRegistries.get(registry);
22534 if (!subRegistry) {
22535 subRegistry = (0,external_wp_data_namespaceObject.createRegistry)({
22536 'core/block-editor': external_wp_blockEditor_namespaceObject.storeConfig
22537 }, registry);
22538 // Todo: The interface store should also be created per instance.
22539 subRegistry.registerStore('core/editor', storeConfig);
22540 subRegistries.set(registry, subRegistry);
22541 }
22542 return subRegistry;
22543 }
22544 const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ({
22545 useSubRegistry = true,
22546 ...props
22547 }) => {
22548 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
22549 const [subRegistries] = (0,external_wp_element_namespaceObject.useState)(() => new WeakMap());
22550 const subRegistry = getSubRegistry(subRegistries, registry, useSubRegistry);
22551 if (subRegistry === registry) {
22552 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
22553 registry: registry,
22554 ...props
22555 });
22556 }
22557 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_data_namespaceObject.RegistryProvider, {
22558 value: subRegistry,
22559 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
22560 registry: subRegistry,
22561 ...props
22562 })
22563 });
22564 }, 'withRegistryProvider');
22565 /* harmony default export */ const with_registry_provider = (withRegistryProvider);
22566
22567 ;// ./packages/editor/build-module/components/media-categories/index.js
22568 /* wp:polyfill */
22569 /**
22570 * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.
22571 * See `packages/editor/src/components/media-categories/index.js`.
22572 *
22573 * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.
22574 * The rest of the settings would still need to be in sync though.
22575 */
22576
22577 /**
22578 * WordPress dependencies
22579 */
22580
22581
22582
22583
22584 /**
22585 * Internal dependencies
22586 */
22587
22588
22589 /** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */
22590 /** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */
22591 /** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */
22592
22593 const getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
22594 const getExternalLinkAttributes = url => `href="${url}" target="_blank" rel="noreferrer noopener"`;
22595 const getOpenverseLicense = (license, licenseVersion) => {
22596 let licenseName = license.trim();
22597 // PDM has no abbreviation
22598 if (license !== 'pdm') {
22599 licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling');
22600 }
22601 // If version is known, append version to the name.
22602 // The license has to have a version to be valid. Only
22603 // PDM (public domain mark) doesn't have a version.
22604 if (licenseVersion) {
22605 licenseName += ` ${licenseVersion}`;
22606 }
22607 // For licenses other than public-domain marks, prepend 'CC' to the name.
22608 if (!['pdm', 'cc0'].includes(license)) {
22609 licenseName = `CC ${licenseName}`;
22610 }
22611 return licenseName;
22612 };
22613 const getOpenverseCaption = item => {
22614 const {
22615 title,
22616 foreign_landing_url: foreignLandingUrl,
22617 creator,
22618 creator_url: creatorUrl,
22619 license,
22620 license_version: licenseVersion,
22621 license_url: licenseUrl
22622 } = item;
22623 const fullLicense = getOpenverseLicense(license, licenseVersion);
22624 const _creator = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(creator);
22625 let _caption;
22626 if (_creator) {
22627 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
22628 // 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".
22629 (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)(
22630 // 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".
22631 (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);
22632 } else {
22633 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
22634 // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
22635 (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)(
22636 // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
22637 (0,external_wp_i18n_namespaceObject._x)('<a %1$s>Work</a>/ %2$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
22638 }
22639 return _caption.replace(/\s{2}/g, ' ');
22640 };
22641 const coreMediaFetch = async (query = {}) => {
22642 const mediaItems = await (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store).getMediaItems({
22643 ...query,
22644 orderBy: !!query?.search ? 'relevance' : 'date'
22645 });
22646 return mediaItems.map(mediaItem => ({
22647 ...mediaItem,
22648 alt: mediaItem.alt_text,
22649 url: mediaItem.source_url,
22650 previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
22651 caption: mediaItem.caption?.raw
22652 }));
22653 };
22654
22655 /** @type {InserterMediaCategory[]} */
22656 const inserterMediaCategories = [{
22657 name: 'images',
22658 labels: {
22659 name: (0,external_wp_i18n_namespaceObject.__)('Images'),
22660 search_items: (0,external_wp_i18n_namespaceObject.__)('Search images')
22661 },
22662 mediaType: 'image',
22663 async fetch(query = {}) {
22664 return coreMediaFetch({
22665 ...query,
22666 media_type: 'image'
22667 });
22668 }
22669 }, {
22670 name: 'videos',
22671 labels: {
22672 name: (0,external_wp_i18n_namespaceObject.__)('Videos'),
22673 search_items: (0,external_wp_i18n_namespaceObject.__)('Search videos')
22674 },
22675 mediaType: 'video',
22676 async fetch(query = {}) {
22677 return coreMediaFetch({
22678 ...query,
22679 media_type: 'video'
22680 });
22681 }
22682 }, {
22683 name: 'audio',
22684 labels: {
22685 name: (0,external_wp_i18n_namespaceObject.__)('Audio'),
22686 search_items: (0,external_wp_i18n_namespaceObject.__)('Search audio')
22687 },
22688 mediaType: 'audio',
22689 async fetch(query = {}) {
22690 return coreMediaFetch({
22691 ...query,
22692 media_type: 'audio'
22693 });
22694 }
22695 }, {
22696 name: 'openverse',
22697 labels: {
22698 name: (0,external_wp_i18n_namespaceObject.__)('Openverse'),
22699 search_items: (0,external_wp_i18n_namespaceObject.__)('Search Openverse')
22700 },
22701 mediaType: 'image',
22702 async fetch(query = {}) {
22703 const defaultArgs = {
22704 mature: false,
22705 excluded_source: 'flickr,inaturalist,wikimedia',
22706 license: 'pdm,cc0'
22707 };
22708 const finalQuery = {
22709 ...query,
22710 ...defaultArgs
22711 };
22712 const mapFromInserterMediaRequest = {
22713 per_page: 'page_size',
22714 search: 'q'
22715 };
22716 const url = new URL('https://api.openverse.org/v1/images/');
22717 Object.entries(finalQuery).forEach(([key, value]) => {
22718 const queryKey = mapFromInserterMediaRequest[key] || key;
22719 url.searchParams.set(queryKey, value);
22720 });
22721 const response = await window.fetch(url, {
22722 headers: {
22723 'User-Agent': 'WordPress/inserter-media-fetch'
22724 }
22725 });
22726 const jsonResponse = await response.json();
22727 const results = jsonResponse.results;
22728 return results.map(result => ({
22729 ...result,
22730 // This is a temp solution for better titles, until Openverse API
22731 // completes the cleaning up of some titles of their upstream data.
22732 title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title,
22733 sourceId: result.id,
22734 id: undefined,
22735 caption: getOpenverseCaption(result),
22736 previewUrl: result.thumbnail
22737 }));
22738 },
22739 getReportUrl: ({
22740 sourceId
22741 }) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
22742 isExternalResource: true
22743 }];
22744 /* harmony default export */ const media_categories = (inserterMediaCategories);
22745
22746 ;// ./packages/editor/build-module/utils/media-upload/index.js
22747 /**
22748 * External dependencies
22749 */
22750
22751
22752 /**
22753 * WordPress dependencies
22754 */
22755
22756
22757
22758 /**
22759 * Internal dependencies
22760 */
22761
22762 const media_upload_noop = () => {};
22763
22764 /**
22765 * Upload a media file when the file upload button is activated.
22766 * Wrapper around mediaUpload() that injects the current post ID.
22767 *
22768 * @param {Object} $0 Parameters object passed to the function.
22769 * @param {?Object} $0.additionalData Additional data to include in the request.
22770 * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.
22771 * @param {Array} $0.filesList List of files.
22772 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.
22773 * @param {Function} $0.onError Function called when an error happens.
22774 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.
22775 */
22776 function mediaUpload({
22777 additionalData = {},
22778 allowedTypes,
22779 filesList,
22780 maxUploadFileSize,
22781 onError = media_upload_noop,
22782 onFileChange
22783 }) {
22784 const {
22785 getCurrentPost,
22786 getEditorSettings
22787 } = (0,external_wp_data_namespaceObject.select)(store_store);
22788 const {
22789 lockPostAutosaving,
22790 unlockPostAutosaving,
22791 lockPostSaving,
22792 unlockPostSaving
22793 } = (0,external_wp_data_namespaceObject.dispatch)(store_store);
22794 const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
22795 const lockKey = `image-upload-${esm_browser_v4()}`;
22796 let imageIsUploading = false;
22797 maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize;
22798 const currentPost = getCurrentPost();
22799 // Templates and template parts' numerical ID is stored in `wp_id`.
22800 const currentPostId = typeof currentPost?.id === 'number' ? currentPost.id : currentPost?.wp_id;
22801 const setSaveLock = () => {
22802 lockPostSaving(lockKey);
22803 lockPostAutosaving(lockKey);
22804 imageIsUploading = true;
22805 };
22806 const postData = currentPostId ? {
22807 post: currentPostId
22808 } : {};
22809 const clearSaveLock = () => {
22810 unlockPostSaving(lockKey);
22811 unlockPostAutosaving(lockKey);
22812 imageIsUploading = false;
22813 };
22814 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
22815 allowedTypes,
22816 filesList,
22817 onFileChange: file => {
22818 if (!imageIsUploading) {
22819 setSaveLock();
22820 } else {
22821 clearSaveLock();
22822 }
22823 onFileChange(file);
22824 },
22825 additionalData: {
22826 ...postData,
22827 ...additionalData
22828 },
22829 maxUploadFileSize,
22830 onError: ({
22831 message
22832 }) => {
22833 clearSaveLock();
22834 onError(message);
22835 },
22836 wpAllowedMimeTypes
22837 });
22838 }
22839
22840 // EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js
22841 var cjs = __webpack_require__(66);
22842 var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
22843 ;// ./node_modules/is-plain-object/dist/is-plain-object.mjs
22844 /*!
22845 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
22846 *
22847 * Copyright (c) 2014-2017, Jon Schlinkert.
22848 * Released under the MIT License.
22849 */
22850
22851 function isObject(o) {
22852 return Object.prototype.toString.call(o) === '[object Object]';
22853 }
22854
22855 function isPlainObject(o) {
22856 var ctor,prot;
22857
22858 if (isObject(o) === false) return false;
22859
22860 // If has modified constructor
22861 ctor = o.constructor;
22862 if (ctor === undefined) return true;
22863
22864 // If has modified prototype
22865 prot = ctor.prototype;
22866 if (isObject(prot) === false) return false;
22867
22868 // If constructor does not have an Object-specific method
22869 if (prot.hasOwnProperty('isPrototypeOf') === false) {
22870 return false;
22871 }
22872
22873 // Most likely a plain Object
22874 return true;
22875 }
22876
22877
22878
22879 ;// ./packages/editor/build-module/components/global-styles-provider/index.js
22880 /**
22881 * External dependencies
22882 */
22883
22884
22885
22886 /**
22887 * WordPress dependencies
22888 */
22889
22890
22891
22892
22893
22894 /**
22895 * Internal dependencies
22896 */
22897
22898
22899 const {
22900 GlobalStylesContext: global_styles_provider_GlobalStylesContext,
22901 cleanEmptyObject
22902 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
22903 function mergeBaseAndUserConfigs(base, user) {
22904 return cjs_default()(base, user, {
22905 /*
22906 * We only pass as arrays the presets,
22907 * in which case we want the new array of values
22908 * to override the old array (no merging).
22909 */
22910 isMergeableObject: isPlainObject,
22911 /*
22912 * Exceptions to the above rule.
22913 * Background images should be replaced, not merged,
22914 * as they themselves are specific object definitions for the style.
22915 */
22916 customMerge: key => {
22917 if (key === 'backgroundImage') {
22918 return (baseConfig, userConfig) => userConfig;
22919 }
22920 return undefined;
22921 }
22922 });
22923 }
22924 function useGlobalStylesUserConfig() {
22925 const {
22926 globalStylesId,
22927 isReady,
22928 settings,
22929 styles,
22930 _links
22931 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22932 const {
22933 getEntityRecord,
22934 getEditedEntityRecord,
22935 hasFinishedResolution,
22936 canUser
22937 } = select(external_wp_coreData_namespaceObject.store);
22938 const _globalStylesId = select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentGlobalStylesId();
22939 let record;
22940
22941 // We want the global styles ID request to finish before triggering
22942 // the OPTIONS request for user capabilities, otherwise it will
22943 // fetch `/wp/v2/global-styles` instead of
22944 // `/wp/v2/global-styles/{id}`!
22945 // Please adjust the preloaded requests if this changes!
22946 const userCanEditGlobalStyles = _globalStylesId ? canUser('update', {
22947 kind: 'root',
22948 name: 'globalStyles',
22949 id: _globalStylesId
22950 }) : null;
22951 if (_globalStylesId &&
22952 // We want the OPTIONS request for user capabilities to finish
22953 // before getting the records, otherwise we'll fetch both!
22954 typeof userCanEditGlobalStyles === 'boolean') {
22955 // Please adjust the preloaded requests if this changes!
22956 if (userCanEditGlobalStyles) {
22957 record = getEditedEntityRecord('root', 'globalStyles', _globalStylesId);
22958 } else {
22959 record = getEntityRecord('root', 'globalStyles', _globalStylesId, {
22960 context: 'view'
22961 });
22962 }
22963 }
22964 let hasResolved = false;
22965 if (hasFinishedResolution('__experimentalGetCurrentGlobalStylesId')) {
22966 if (_globalStylesId) {
22967 hasResolved = userCanEditGlobalStyles ? hasFinishedResolution('getEditedEntityRecord', ['root', 'globalStyles', _globalStylesId]) : hasFinishedResolution('getEntityRecord', ['root', 'globalStyles', _globalStylesId, {
22968 context: 'view'
22969 }]);
22970 } else {
22971 hasResolved = true;
22972 }
22973 }
22974 return {
22975 globalStylesId: _globalStylesId,
22976 isReady: hasResolved,
22977 settings: record?.settings,
22978 styles: record?.styles,
22979 _links: record?._links
22980 };
22981 }, []);
22982 const {
22983 getEditedEntityRecord
22984 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
22985 const {
22986 editEntityRecord
22987 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
22988 const config = (0,external_wp_element_namespaceObject.useMemo)(() => {
22989 return {
22990 settings: settings !== null && settings !== void 0 ? settings : {},
22991 styles: styles !== null && styles !== void 0 ? styles : {},
22992 _links: _links !== null && _links !== void 0 ? _links : {}
22993 };
22994 }, [settings, styles, _links]);
22995 const setConfig = (0,external_wp_element_namespaceObject.useCallback)(
22996 /**
22997 * Set the global styles config.
22998 * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.
22999 * Otherwise, overwrite the current config with the incoming object.
23000 * @param {Object} options Options for editEntityRecord Core selector.
23001 */
23002 (callbackOrObject, options = {}) => {
23003 var _record$styles, _record$settings, _record$_links;
23004 const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
23005 const currentConfig = {
23006 styles: (_record$styles = record?.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
23007 settings: (_record$settings = record?.settings) !== null && _record$settings !== void 0 ? _record$settings : {},
23008 _links: (_record$_links = record?._links) !== null && _record$_links !== void 0 ? _record$_links : {}
23009 };
23010 const updatedConfig = typeof callbackOrObject === 'function' ? callbackOrObject(currentConfig) : callbackOrObject;
23011 editEntityRecord('root', 'globalStyles', globalStylesId, {
23012 styles: cleanEmptyObject(updatedConfig.styles) || {},
23013 settings: cleanEmptyObject(updatedConfig.settings) || {},
23014 _links: cleanEmptyObject(updatedConfig._links) || {}
23015 }, options);
23016 }, [globalStylesId, editEntityRecord, getEditedEntityRecord]);
23017 return [isReady, config, setConfig];
23018 }
23019 function useGlobalStylesBaseConfig() {
23020 const baseConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeBaseGlobalStyles(), []);
23021 return [!!baseConfig, baseConfig];
23022 }
23023 function useGlobalStylesContext() {
23024 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
23025 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
23026 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
23027 if (!baseConfig || !userConfig) {
23028 return {};
23029 }
23030 return mergeBaseAndUserConfigs(baseConfig, userConfig);
23031 }, [userConfig, baseConfig]);
23032 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
23033 return {
23034 isReady: isUserConfigReady && isBaseConfigReady,
23035 user: userConfig,
23036 base: baseConfig,
23037 merged: mergedConfig,
23038 setUserConfig
23039 };
23040 }, [mergedConfig, userConfig, baseConfig, setUserConfig, isUserConfigReady, isBaseConfigReady]);
23041 return context;
23042 }
23043 function GlobalStylesProvider({
23044 children
23045 }) {
23046 const context = useGlobalStylesContext();
23047 if (!context.isReady) {
23048 return null;
23049 }
23050 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(global_styles_provider_GlobalStylesContext.Provider, {
23051 value: context,
23052 children: children
23053 });
23054 }
23055
23056 ;// ./packages/editor/build-module/components/provider/use-block-editor-settings.js
23057 /**
23058 * WordPress dependencies
23059 */
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069 /**
23070 * Internal dependencies
23071 */
23072
23073
23074
23075
23076
23077 const use_block_editor_settings_EMPTY_OBJECT = {};
23078 function __experimentalReusableBlocksSelect(select) {
23079 const {
23080 getEntityRecords,
23081 hasFinishedResolution
23082 } = select(external_wp_coreData_namespaceObject.store);
23083 const reusableBlocks = getEntityRecords('postType', 'wp_block', {
23084 per_page: -1
23085 });
23086 return hasFinishedResolution('getEntityRecords', ['postType', 'wp_block', {
23087 per_page: -1
23088 }]) ? reusableBlocks : undefined;
23089 }
23090 const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', 'alignWide', 'blockInspectorTabs', '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'];
23091 const {
23092 globalStylesDataKey,
23093 globalStylesLinksDataKey,
23094 selectBlockPatternsKey,
23095 reusableBlocksSelectKey,
23096 sectionRootClientIdKey
23097 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
23098
23099 /**
23100 * React hook used to compute the block editor settings to use for the post editor.
23101 *
23102 * @param {Object} settings EditorProvider settings prop.
23103 * @param {string} postType Editor root level post type.
23104 * @param {string} postId Editor root level post ID.
23105 * @param {string} renderingMode Editor rendering mode.
23106 *
23107 * @return {Object} Block Editor Settings.
23108 */
23109 function useBlockEditorSettings(settings, postType, postId, renderingMode) {
23110 var _mergedGlobalStyles$s, _mergedGlobalStyles$_, _settings$__experimen, _settings$__experimen2;
23111 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
23112 const {
23113 allowRightClickOverrides,
23114 blockTypes,
23115 focusMode,
23116 hasFixedToolbar,
23117 isDistractionFree,
23118 keepCaretInsideBlock,
23119 hasUploadPermissions,
23120 hiddenBlockTypes,
23121 canUseUnfilteredHTML,
23122 userCanCreatePages,
23123 pageOnFront,
23124 pageForPosts,
23125 userPatternCategories,
23126 restBlockPatternCategories,
23127 sectionRootClientId
23128 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23129 var _canUser;
23130 const {
23131 canUser,
23132 getRawEntityRecord,
23133 getEntityRecord,
23134 getUserPatternCategories,
23135 getBlockPatternCategories
23136 } = select(external_wp_coreData_namespaceObject.store);
23137 const {
23138 get
23139 } = select(external_wp_preferences_namespaceObject.store);
23140 const {
23141 getBlockTypes
23142 } = select(external_wp_blocks_namespaceObject.store);
23143 const {
23144 getBlocksByName,
23145 getBlockAttributes
23146 } = select(external_wp_blockEditor_namespaceObject.store);
23147 const siteSettings = canUser('read', {
23148 kind: 'root',
23149 name: 'site'
23150 }) ? getEntityRecord('root', 'site') : undefined;
23151 function getSectionRootBlock() {
23152 var _getBlocksByName$find;
23153 if (renderingMode === 'template-locked') {
23154 var _getBlocksByName$;
23155 return (_getBlocksByName$ = getBlocksByName('core/post-content')?.[0]) !== null && _getBlocksByName$ !== void 0 ? _getBlocksByName$ : '';
23156 }
23157 return (_getBlocksByName$find = getBlocksByName('core/group').find(clientId => getBlockAttributes(clientId)?.tagName === 'main')) !== null && _getBlocksByName$find !== void 0 ? _getBlocksByName$find : '';
23158 }
23159 return {
23160 allowRightClickOverrides: get('core', 'allowRightClickOverrides'),
23161 blockTypes: getBlockTypes(),
23162 canUseUnfilteredHTML: getRawEntityRecord('postType', postType, postId)?._links?.hasOwnProperty('wp:action-unfiltered-html'),
23163 focusMode: get('core', 'focusMode'),
23164 hasFixedToolbar: get('core', 'fixedToolbar') || !isLargeViewport,
23165 hiddenBlockTypes: get('core', 'hiddenBlockTypes'),
23166 isDistractionFree: get('core', 'distractionFree'),
23167 keepCaretInsideBlock: get('core', 'keepCaretInsideBlock'),
23168 hasUploadPermissions: (_canUser = canUser('create', {
23169 kind: 'root',
23170 name: 'media'
23171 })) !== null && _canUser !== void 0 ? _canUser : true,
23172 userCanCreatePages: canUser('create', {
23173 kind: 'postType',
23174 name: 'page'
23175 }),
23176 pageOnFront: siteSettings?.page_on_front,
23177 pageForPosts: siteSettings?.page_for_posts,
23178 userPatternCategories: getUserPatternCategories(),
23179 restBlockPatternCategories: getBlockPatternCategories(),
23180 sectionRootClientId: getSectionRootBlock()
23181 };
23182 }, [postType, postId, isLargeViewport, renderingMode]);
23183 const {
23184 merged: mergedGlobalStyles
23185 } = useGlobalStylesContext();
23186 const globalStylesData = (_mergedGlobalStyles$s = mergedGlobalStyles.styles) !== null && _mergedGlobalStyles$s !== void 0 ? _mergedGlobalStyles$s : use_block_editor_settings_EMPTY_OBJECT;
23187 const globalStylesLinksData = (_mergedGlobalStyles$_ = mergedGlobalStyles._links) !== null && _mergedGlobalStyles$_ !== void 0 ? _mergedGlobalStyles$_ : use_block_editor_settings_EMPTY_OBJECT;
23188 const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen :
23189 // WP 6.0
23190 settings.__experimentalBlockPatterns; // WP 5.9
23191 const settingsBlockPatternCategories = (_settings$__experimen2 = settings.__experimentalAdditionalBlockPatternCategories) !== null && _settings$__experimen2 !== void 0 ? _settings$__experimen2 :
23192 // WP 6.0
23193 settings.__experimentalBlockPatternCategories; // WP 5.9
23194
23195 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || [])].filter(({
23196 postTypes
23197 }) => {
23198 return !postTypes || Array.isArray(postTypes) && postTypes.includes(postType);
23199 }), [settingsBlockPatterns, postType]);
23200 const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatternCategories || []), ...(restBlockPatternCategories || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)), [settingsBlockPatternCategories, restBlockPatternCategories]);
23201 const {
23202 undo,
23203 setIsInserterOpened
23204 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23205 const {
23206 saveEntityRecord
23207 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
23208
23209 /**
23210 * Creates a Post entity.
23211 * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.
23212 *
23213 * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.
23214 * @return {Object} the post type object that was created.
23215 */
23216 const createPageEntity = (0,external_wp_element_namespaceObject.useCallback)(options => {
23217 if (!userCanCreatePages) {
23218 return Promise.reject({
23219 message: (0,external_wp_i18n_namespaceObject.__)('You do not have permission to create Pages.')
23220 });
23221 }
23222 return saveEntityRecord('postType', 'page', options);
23223 }, [saveEntityRecord, userCanCreatePages]);
23224 const allowedBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
23225 // Omit hidden block types if exists and non-empty.
23226 if (hiddenBlockTypes && hiddenBlockTypes.length > 0) {
23227 // Defer to passed setting for `allowedBlockTypes` if provided as
23228 // anything other than `true` (where `true` is equivalent to allow
23229 // all block types).
23230 const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? blockTypes.map(({
23231 name
23232 }) => name) : settings.allowedBlockTypes || [];
23233 return defaultAllowedBlockTypes.filter(type => !hiddenBlockTypes.includes(type));
23234 }
23235 return settings.allowedBlockTypes;
23236 }, [settings.allowedBlockTypes, hiddenBlockTypes, blockTypes]);
23237 const forceDisableFocusMode = settings.focusMode === false;
23238 return (0,external_wp_element_namespaceObject.useMemo)(() => {
23239 const blockEditorSettings = {
23240 ...Object.fromEntries(Object.entries(settings).filter(([key]) => BLOCK_EDITOR_SETTINGS.includes(key))),
23241 [globalStylesDataKey]: globalStylesData,
23242 [globalStylesLinksDataKey]: globalStylesLinksData,
23243 allowedBlockTypes,
23244 allowRightClickOverrides,
23245 focusMode: focusMode && !forceDisableFocusMode,
23246 hasFixedToolbar,
23247 isDistractionFree,
23248 keepCaretInsideBlock,
23249 mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
23250 __experimentalBlockPatterns: blockPatterns,
23251 [selectBlockPatternsKey]: select => {
23252 const {
23253 hasFinishedResolution,
23254 getBlockPatternsForPostType
23255 } = unlock(select(external_wp_coreData_namespaceObject.store));
23256 const patterns = getBlockPatternsForPostType(postType);
23257 return hasFinishedResolution('getBlockPatterns') ? patterns : undefined;
23258 },
23259 [reusableBlocksSelectKey]: __experimentalReusableBlocksSelect,
23260 __experimentalBlockPatternCategories: blockPatternCategories,
23261 __experimentalUserPatternCategories: userPatternCategories,
23262 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
23263 inserterMediaCategories: media_categories,
23264 __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData,
23265 // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.
23266 // This might be better as a generic "canUser" selector.
23267 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
23268 //Todo: this is only needed for native and should probably be removed.
23269 __experimentalUndo: undo,
23270 // Check whether we want all site editor frames to have outlines
23271 // including the navigation / pattern / parts editors.
23272 outlineMode: !isDistractionFree && postType === 'wp_template',
23273 // Check these two properties: they were not present in the site editor.
23274 __experimentalCreatePageEntity: createPageEntity,
23275 __experimentalUserCanCreatePages: userCanCreatePages,
23276 pageOnFront,
23277 pageForPosts,
23278 __experimentalPreferPatternsOnRoot: postType === 'wp_template',
23279 templateLock: postType === 'wp_navigation' ? 'insert' : settings.templateLock,
23280 template: postType === 'wp_navigation' ? [['core/navigation', {}, []]] : settings.template,
23281 __experimentalSetIsInserterOpened: setIsInserterOpened,
23282 [sectionRootClientIdKey]: sectionRootClientId
23283 };
23284 return blockEditorSettings;
23285 }, [allowedBlockTypes, allowRightClickOverrides, focusMode, forceDisableFocusMode, hasFixedToolbar, isDistractionFree, keepCaretInsideBlock, settings, hasUploadPermissions, userPatternCategories, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, createPageEntity, userCanCreatePages, pageOnFront, pageForPosts, postType, setIsInserterOpened, sectionRootClientId, globalStylesData, globalStylesLinksData]);
23286 }
23287 /* harmony default export */ const use_block_editor_settings = (useBlockEditorSettings);
23288
23289 ;// ./packages/editor/build-module/components/provider/use-post-content-blocks.js
23290 /**
23291 * WordPress dependencies
23292 */
23293
23294
23295
23296
23297 /**
23298 * Internal dependencies
23299 */
23300
23301
23302 const POST_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
23303 function usePostContentBlocks() {
23304 const contentOnlyBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => [...(0,external_wp_hooks_namespaceObject.applyFilters)('editor.postContentBlockTypes', POST_CONTENT_BLOCK_TYPES)], []);
23305
23306 // Note that there are two separate subscriptions because the result for each
23307 // returns a new array.
23308 const contentOnlyIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
23309 const {
23310 getPostBlocksByName
23311 } = unlock(select(store_store));
23312 return getPostBlocksByName(contentOnlyBlockTypes);
23313 }, [contentOnlyBlockTypes]);
23314 return contentOnlyIds;
23315 }
23316
23317 ;// ./packages/editor/build-module/components/provider/disable-non-page-content-blocks.js
23318 /**
23319 * WordPress dependencies
23320 */
23321
23322
23323
23324
23325 /**
23326 * Internal dependencies
23327 */
23328
23329
23330 /**
23331 * Component that when rendered, makes it so that the site editor allows only
23332 * page content to be edited.
23333 */
23334 function DisableNonPageContentBlocks() {
23335 const contentOnlyIds = usePostContentBlocks();
23336 const templateParts = (0,external_wp_data_namespaceObject.useSelect)(select => {
23337 const {
23338 getBlocksByName
23339 } = select(external_wp_blockEditor_namespaceObject.store);
23340 return getBlocksByName('core/template-part');
23341 }, []);
23342 const disabledIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
23343 const {
23344 getBlockOrder
23345 } = select(external_wp_blockEditor_namespaceObject.store);
23346 return templateParts.flatMap(clientId => getBlockOrder(clientId));
23347 }, [templateParts]);
23348 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
23349 (0,external_wp_element_namespaceObject.useEffect)(() => {
23350 const {
23351 setBlockEditingMode,
23352 unsetBlockEditingMode
23353 } = registry.dispatch(external_wp_blockEditor_namespaceObject.store);
23354 registry.batch(() => {
23355 setBlockEditingMode('', 'disabled');
23356 for (const clientId of contentOnlyIds) {
23357 setBlockEditingMode(clientId, 'contentOnly');
23358 }
23359 for (const clientId of templateParts) {
23360 setBlockEditingMode(clientId, 'contentOnly');
23361 }
23362 for (const clientId of disabledIds) {
23363 setBlockEditingMode(clientId, 'disabled');
23364 }
23365 });
23366 return () => {
23367 registry.batch(() => {
23368 unsetBlockEditingMode('');
23369 for (const clientId of contentOnlyIds) {
23370 unsetBlockEditingMode(clientId);
23371 }
23372 for (const clientId of templateParts) {
23373 unsetBlockEditingMode(clientId);
23374 }
23375 for (const clientId of disabledIds) {
23376 unsetBlockEditingMode(clientId);
23377 }
23378 });
23379 };
23380 }, [templateParts, contentOnlyIds, disabledIds, registry]);
23381 return null;
23382 }
23383
23384 ;// ./packages/editor/build-module/components/provider/navigation-block-editing-mode.js
23385 /**
23386 * WordPress dependencies
23387 */
23388
23389
23390
23391
23392 /**
23393 * For the Navigation block editor, we need to force the block editor to contentOnly for that block.
23394 *
23395 * Set block editing mode to contentOnly when entering Navigation focus mode.
23396 * this ensures that non-content controls on the block will be hidden and thus
23397 * the user can focus on editing the Navigation Menu content only.
23398 */
23399
23400 function NavigationBlockEditingMode() {
23401 // In the navigation block editor,
23402 // the navigation block is the only root block.
23403 const blockClientId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlockOrder()?.[0], []);
23404 const {
23405 setBlockEditingMode,
23406 unsetBlockEditingMode
23407 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
23408 (0,external_wp_element_namespaceObject.useEffect)(() => {
23409 if (!blockClientId) {
23410 return;
23411 }
23412 setBlockEditingMode(blockClientId, 'contentOnly');
23413 return () => {
23414 unsetBlockEditingMode(blockClientId);
23415 };
23416 }, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]);
23417 }
23418
23419 ;// ./packages/editor/build-module/components/provider/use-hide-blocks-from-inserter.js
23420 /**
23421 * WordPress dependencies
23422 */
23423
23424
23425
23426 // These post types are "structural" block lists.
23427 // We should be allowed to use
23428 // the post content and template parts blocks within them.
23429 const POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = ['wp_block', 'wp_template', 'wp_template_part'];
23430
23431 /**
23432 * In some specific contexts,
23433 * the template part and post content blocks need to be hidden.
23434 *
23435 * @param {string} postType Post Type
23436 * @param {string} mode Rendering mode
23437 */
23438 function useHideBlocksFromInserter(postType, mode) {
23439 (0,external_wp_element_namespaceObject.useEffect)(() => {
23440 /*
23441 * Prevent adding template part in the editor.
23442 */
23443 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
23444 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/template-part' && mode === 'post-only') {
23445 return false;
23446 }
23447 return canInsert;
23448 });
23449
23450 /*
23451 * Prevent adding post content block (except in query block) in the editor.
23452 */
23453 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter', (canInsert, blockType, rootClientId, {
23454 getBlockParentsByBlockName
23455 }) => {
23456 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/post-content') {
23457 return getBlockParentsByBlockName(rootClientId, 'core/query').length > 0;
23458 }
23459 return canInsert;
23460 });
23461 return () => {
23462 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter');
23463 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter');
23464 };
23465 }, [postType, mode]);
23466 }
23467
23468 ;// ./packages/icons/build-module/library/keyboard.js
23469 /**
23470 * WordPress dependencies
23471 */
23472
23473
23474 const keyboard = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
23475 xmlns: "http://www.w3.org/2000/svg",
23476 viewBox: "0 0 24 24",
23477 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23478 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"
23479 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23480 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"
23481 })]
23482 });
23483 /* harmony default export */ const library_keyboard = (keyboard);
23484
23485 ;// ./packages/icons/build-module/library/list-view.js
23486 /**
23487 * WordPress dependencies
23488 */
23489
23490
23491 const listView = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23492 viewBox: "0 0 24 24",
23493 xmlns: "http://www.w3.org/2000/svg",
23494 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23495 d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z"
23496 })
23497 });
23498 /* harmony default export */ const list_view = (listView);
23499
23500 ;// ./packages/icons/build-module/library/code.js
23501 /**
23502 * WordPress dependencies
23503 */
23504
23505
23506 const code = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23507 viewBox: "0 0 24 24",
23508 xmlns: "http://www.w3.org/2000/svg",
23509 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23510 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"
23511 })
23512 });
23513 /* harmony default export */ const library_code = (code);
23514
23515 ;// ./packages/icons/build-module/library/drawer-left.js
23516 /**
23517 * WordPress dependencies
23518 */
23519
23520
23521 const drawerLeft = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23522 width: "24",
23523 height: "24",
23524 xmlns: "http://www.w3.org/2000/svg",
23525 viewBox: "0 0 24 24",
23526 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23527 fillRule: "evenodd",
23528 clipRule: "evenodd",
23529 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"
23530 })
23531 });
23532 /* harmony default export */ const drawer_left = (drawerLeft);
23533
23534 ;// ./packages/icons/build-module/library/drawer-right.js
23535 /**
23536 * WordPress dependencies
23537 */
23538
23539
23540 const drawerRight = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23541 width: "24",
23542 height: "24",
23543 xmlns: "http://www.w3.org/2000/svg",
23544 viewBox: "0 0 24 24",
23545 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23546 fillRule: "evenodd",
23547 clipRule: "evenodd",
23548 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"
23549 })
23550 });
23551 /* harmony default export */ const drawer_right = (drawerRight);
23552
23553 ;// ./packages/icons/build-module/library/block-default.js
23554 /**
23555 * WordPress dependencies
23556 */
23557
23558
23559 const blockDefault = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23560 xmlns: "http://www.w3.org/2000/svg",
23561 viewBox: "0 0 24 24",
23562 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23563 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"
23564 })
23565 });
23566 /* harmony default export */ const block_default = (blockDefault);
23567
23568 ;// ./packages/icons/build-module/library/format-list-bullets.js
23569 /**
23570 * WordPress dependencies
23571 */
23572
23573
23574 const formatListBullets = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23575 xmlns: "http://www.w3.org/2000/svg",
23576 viewBox: "0 0 24 24",
23577 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23578 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"
23579 })
23580 });
23581 /* harmony default export */ const format_list_bullets = (formatListBullets);
23582
23583 ;// ./packages/icons/build-module/library/pencil.js
23584 /**
23585 * WordPress dependencies
23586 */
23587
23588
23589 const pencil = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23590 xmlns: "http://www.w3.org/2000/svg",
23591 viewBox: "0 0 24 24",
23592 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23593 d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"
23594 })
23595 });
23596 /* harmony default export */ const library_pencil = (pencil);
23597
23598 ;// ./packages/icons/build-module/library/edit.js
23599 /**
23600 * Internal dependencies
23601 */
23602
23603
23604 /* harmony default export */ const edit = (library_pencil);
23605
23606 ;// ./packages/editor/build-module/components/pattern-rename-modal/index.js
23607 /**
23608 * WordPress dependencies
23609 */
23610
23611
23612
23613
23614
23615 /**
23616 * Internal dependencies
23617 */
23618
23619
23620
23621
23622 const {
23623 RenamePatternModal
23624 } = unlock(external_wp_patterns_namespaceObject.privateApis);
23625 const modalName = 'editor/pattern-rename';
23626 function PatternRenameModal() {
23627 const {
23628 record,
23629 postType
23630 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23631 const {
23632 getCurrentPostType,
23633 getCurrentPostId
23634 } = select(store_store);
23635 const {
23636 getEditedEntityRecord
23637 } = select(external_wp_coreData_namespaceObject.store);
23638 const _postType = getCurrentPostType();
23639 return {
23640 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
23641 postType: _postType
23642 };
23643 }, []);
23644 const {
23645 closeModal
23646 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
23647 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(modalName));
23648 if (!isActive || postType !== PATTERN_POST_TYPE) {
23649 return null;
23650 }
23651 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RenamePatternModal, {
23652 onClose: closeModal,
23653 pattern: record
23654 });
23655 }
23656
23657 ;// ./packages/editor/build-module/components/pattern-duplicate-modal/index.js
23658 /**
23659 * WordPress dependencies
23660 */
23661
23662
23663
23664
23665
23666 /**
23667 * Internal dependencies
23668 */
23669
23670
23671
23672
23673 const {
23674 DuplicatePatternModal
23675 } = unlock(external_wp_patterns_namespaceObject.privateApis);
23676 const pattern_duplicate_modal_modalName = 'editor/pattern-duplicate';
23677 function PatternDuplicateModal() {
23678 const {
23679 record,
23680 postType
23681 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23682 const {
23683 getCurrentPostType,
23684 getCurrentPostId
23685 } = select(store_store);
23686 const {
23687 getEditedEntityRecord
23688 } = select(external_wp_coreData_namespaceObject.store);
23689 const _postType = getCurrentPostType();
23690 return {
23691 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
23692 postType: _postType
23693 };
23694 }, []);
23695 const {
23696 closeModal
23697 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
23698 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(pattern_duplicate_modal_modalName));
23699 if (!isActive || postType !== PATTERN_POST_TYPE) {
23700 return null;
23701 }
23702 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DuplicatePatternModal, {
23703 onClose: closeModal,
23704 onSuccess: () => closeModal(),
23705 pattern: record
23706 });
23707 }
23708
23709 ;// ./packages/editor/build-module/components/commands/index.js
23710 /**
23711 * WordPress dependencies
23712 */
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723 /**
23724 * Internal dependencies
23725 */
23726
23727
23728
23729
23730 function useEditorCommandLoader() {
23731 const {
23732 editorMode,
23733 isListViewOpen,
23734 showBlockBreadcrumbs,
23735 isDistractionFree,
23736 isTopToolbar,
23737 isFocusMode,
23738 isPreviewMode,
23739 isViewable,
23740 isCodeEditingEnabled,
23741 isRichEditingEnabled,
23742 isPublishSidebarEnabled
23743 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23744 var _get, _getPostType$viewable;
23745 const {
23746 get
23747 } = select(external_wp_preferences_namespaceObject.store);
23748 const {
23749 isListViewOpened,
23750 getCurrentPostType,
23751 getEditorSettings
23752 } = select(store_store);
23753 const {
23754 getSettings
23755 } = select(external_wp_blockEditor_namespaceObject.store);
23756 const {
23757 getPostType
23758 } = select(external_wp_coreData_namespaceObject.store);
23759 return {
23760 editorMode: (_get = get('core', 'editorMode')) !== null && _get !== void 0 ? _get : 'visual',
23761 isListViewOpen: isListViewOpened(),
23762 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
23763 isDistractionFree: get('core', 'distractionFree'),
23764 isFocusMode: get('core', 'focusMode'),
23765 isTopToolbar: get('core', 'fixedToolbar'),
23766 isPreviewMode: getSettings().isPreviewMode,
23767 isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
23768 isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
23769 isRichEditingEnabled: getEditorSettings().richEditingEnabled,
23770 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled()
23771 };
23772 }, []);
23773 const {
23774 getActiveComplementaryArea
23775 } = (0,external_wp_data_namespaceObject.useSelect)(store);
23776 const {
23777 toggle
23778 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
23779 const {
23780 createInfoNotice
23781 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
23782 const {
23783 __unstableSaveForPreview,
23784 setIsListViewOpened,
23785 switchEditorMode,
23786 toggleDistractionFree
23787 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23788 const {
23789 openModal,
23790 enableComplementaryArea,
23791 disableComplementaryArea
23792 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
23793 const {
23794 getCurrentPostId
23795 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
23796 const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
23797 if (isPreviewMode) {
23798 return {
23799 commands: [],
23800 isLoading: false
23801 };
23802 }
23803 const commands = [];
23804 commands.push({
23805 name: 'core/open-shortcut-help',
23806 label: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
23807 icon: library_keyboard,
23808 callback: ({
23809 close
23810 }) => {
23811 close();
23812 openModal('editor/keyboard-shortcut-help');
23813 }
23814 });
23815 commands.push({
23816 name: 'core/toggle-distraction-free',
23817 label: isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Exit Distraction free') : (0,external_wp_i18n_namespaceObject.__)('Enter Distraction free'),
23818 callback: ({
23819 close
23820 }) => {
23821 toggleDistractionFree();
23822 close();
23823 }
23824 });
23825 commands.push({
23826 name: 'core/open-preferences',
23827 label: (0,external_wp_i18n_namespaceObject.__)('Editor preferences'),
23828 callback: ({
23829 close
23830 }) => {
23831 close();
23832 openModal('editor/preferences');
23833 }
23834 });
23835 commands.push({
23836 name: 'core/toggle-spotlight-mode',
23837 label: isFocusMode ? (0,external_wp_i18n_namespaceObject.__)('Exit Spotlight mode') : (0,external_wp_i18n_namespaceObject.__)('Enter Spotlight mode'),
23838 callback: ({
23839 close
23840 }) => {
23841 toggle('core', 'focusMode');
23842 close();
23843 createInfoNotice(isFocusMode ? (0,external_wp_i18n_namespaceObject.__)('Spotlight off.') : (0,external_wp_i18n_namespaceObject.__)('Spotlight on.'), {
23844 id: 'core/editor/toggle-spotlight-mode/notice',
23845 type: 'snackbar',
23846 actions: [{
23847 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
23848 onClick: () => {
23849 toggle('core', 'focusMode');
23850 }
23851 }]
23852 });
23853 }
23854 });
23855 commands.push({
23856 name: 'core/toggle-list-view',
23857 label: isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('Close List View') : (0,external_wp_i18n_namespaceObject.__)('Open List View'),
23858 icon: list_view,
23859 callback: ({
23860 close
23861 }) => {
23862 setIsListViewOpened(!isListViewOpen);
23863 close();
23864 createInfoNotice(isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View off.') : (0,external_wp_i18n_namespaceObject.__)('List View on.'), {
23865 id: 'core/editor/toggle-list-view/notice',
23866 type: 'snackbar'
23867 });
23868 }
23869 });
23870 commands.push({
23871 name: 'core/toggle-top-toolbar',
23872 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
23873 callback: ({
23874 close
23875 }) => {
23876 toggle('core', 'fixedToolbar');
23877 if (isDistractionFree) {
23878 toggleDistractionFree();
23879 }
23880 close();
23881 createInfoNotice(isTopToolbar ? (0,external_wp_i18n_namespaceObject.__)('Top toolbar off.') : (0,external_wp_i18n_namespaceObject.__)('Top toolbar on.'), {
23882 id: 'core/editor/toggle-top-toolbar/notice',
23883 type: 'snackbar',
23884 actions: [{
23885 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
23886 onClick: () => {
23887 toggle('core', 'fixedToolbar');
23888 }
23889 }]
23890 });
23891 }
23892 });
23893 if (allowSwitchEditorMode) {
23894 commands.push({
23895 name: 'core/toggle-code-editor',
23896 label: editorMode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Open code editor') : (0,external_wp_i18n_namespaceObject.__)('Exit code editor'),
23897 icon: library_code,
23898 callback: ({
23899 close
23900 }) => {
23901 switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
23902 close();
23903 }
23904 });
23905 }
23906 commands.push({
23907 name: 'core/toggle-breadcrumbs',
23908 label: showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Hide block breadcrumbs') : (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs'),
23909 callback: ({
23910 close
23911 }) => {
23912 toggle('core', 'showBlockBreadcrumbs');
23913 close();
23914 createInfoNotice(showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs hidden.') : (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs visible.'), {
23915 id: 'core/editor/toggle-breadcrumbs/notice',
23916 type: 'snackbar'
23917 });
23918 }
23919 });
23920 commands.push({
23921 name: 'core/open-settings-sidebar',
23922 label: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings panel.'),
23923 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
23924 callback: ({
23925 close
23926 }) => {
23927 const activeSidebar = getActiveComplementaryArea('core');
23928 close();
23929 if (activeSidebar === 'edit-post/document') {
23930 disableComplementaryArea('core');
23931 } else {
23932 enableComplementaryArea('core', 'edit-post/document');
23933 }
23934 }
23935 });
23936 commands.push({
23937 name: 'core/open-block-inspector',
23938 label: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Block settings panel'),
23939 icon: block_default,
23940 callback: ({
23941 close
23942 }) => {
23943 const activeSidebar = getActiveComplementaryArea('core');
23944 close();
23945 if (activeSidebar === 'edit-post/block') {
23946 disableComplementaryArea('core');
23947 } else {
23948 enableComplementaryArea('core', 'edit-post/block');
23949 }
23950 }
23951 });
23952 commands.push({
23953 name: 'core/toggle-publish-sidebar',
23954 label: isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Disable pre-publish checks') : (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks'),
23955 icon: format_list_bullets,
23956 callback: ({
23957 close
23958 }) => {
23959 close();
23960 toggle('core', 'isPublishSidebarEnabled');
23961 createInfoNotice(isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks disabled.') : (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks enabled.'), {
23962 id: 'core/editor/publish-sidebar/notice',
23963 type: 'snackbar'
23964 });
23965 }
23966 });
23967 if (isViewable) {
23968 commands.push({
23969 name: 'core/preview-link',
23970 label: (0,external_wp_i18n_namespaceObject.__)('Preview in a new tab'),
23971 icon: library_external,
23972 callback: async ({
23973 close
23974 }) => {
23975 close();
23976 const postId = getCurrentPostId();
23977 const link = await __unstableSaveForPreview();
23978 window.open(link, `wp-preview-${postId}`);
23979 }
23980 });
23981 }
23982 return {
23983 commands,
23984 isLoading: false
23985 };
23986 }
23987 function useEditedEntityContextualCommands() {
23988 const {
23989 postType
23990 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23991 const {
23992 getCurrentPostType
23993 } = select(store_store);
23994 return {
23995 postType: getCurrentPostType()
23996 };
23997 }, []);
23998 const {
23999 openModal
24000 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
24001 const commands = [];
24002 if (postType === PATTERN_POST_TYPE) {
24003 commands.push({
24004 name: 'core/rename-pattern',
24005 label: (0,external_wp_i18n_namespaceObject.__)('Rename pattern'),
24006 icon: edit,
24007 callback: ({
24008 close
24009 }) => {
24010 openModal(modalName);
24011 close();
24012 }
24013 });
24014 commands.push({
24015 name: 'core/duplicate-pattern',
24016 label: (0,external_wp_i18n_namespaceObject.__)('Duplicate pattern'),
24017 icon: library_symbol,
24018 callback: ({
24019 close
24020 }) => {
24021 openModal(pattern_duplicate_modal_modalName);
24022 close();
24023 }
24024 });
24025 }
24026 return {
24027 isLoading: false,
24028 commands
24029 };
24030 }
24031 function useCommands() {
24032 (0,external_wp_commands_namespaceObject.useCommandLoader)({
24033 name: 'core/editor/edit-ui',
24034 hook: useEditorCommandLoader
24035 });
24036 (0,external_wp_commands_namespaceObject.useCommandLoader)({
24037 name: 'core/editor/contextual-commands',
24038 hook: useEditedEntityContextualCommands,
24039 context: 'entity-edit'
24040 });
24041 }
24042
24043 ;// ./packages/editor/build-module/components/block-removal-warnings/index.js
24044 /**
24045 * WordPress dependencies
24046 */
24047
24048
24049
24050
24051
24052
24053 /**
24054 * Internal dependencies
24055 */
24056
24057
24058
24059 const {
24060 BlockRemovalWarningModal
24061 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
24062
24063 // Prevent accidental removal of certain blocks, asking the user for confirmation first.
24064 const TEMPLATE_BLOCKS = ['core/post-content', 'core/post-template', 'core/query'];
24065 const BLOCK_REMOVAL_RULES = [{
24066 // Template blocks.
24067 // The warning is only shown when a user manipulates templates or template parts.
24068 postTypes: ['wp_template', 'wp_template_part'],
24069 callback(removedBlocks) {
24070 const removedTemplateBlocks = removedBlocks.filter(({
24071 name
24072 }) => TEMPLATE_BLOCKS.includes(name));
24073 if (removedTemplateBlocks.length) {
24074 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);
24075 }
24076 }
24077 }, {
24078 // Pattern overrides.
24079 // The warning is only shown when the user edits a pattern.
24080 postTypes: ['wp_block'],
24081 callback(removedBlocks) {
24082 const removedBlocksWithOverrides = removedBlocks.filter(({
24083 attributes
24084 }) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some(binding => binding.source === 'core/pattern-overrides'));
24085 if (removedBlocksWithOverrides.length) {
24086 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);
24087 }
24088 }
24089 }];
24090 function BlockRemovalWarnings() {
24091 const currentPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
24092 const removalRulesForPostType = (0,external_wp_element_namespaceObject.useMemo)(() => BLOCK_REMOVAL_RULES.filter(rule => rule.postTypes.includes(currentPostType)), [currentPostType]);
24093
24094 // `BlockRemovalWarnings` is rendered in the editor provider, a shared component
24095 // across react native and web. However, `BlockRemovalWarningModal` is web only.
24096 // Check it exists before trying to render it.
24097 if (!BlockRemovalWarningModal) {
24098 return null;
24099 }
24100 if (!removalRulesForPostType) {
24101 return null;
24102 }
24103 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockRemovalWarningModal, {
24104 rules: removalRulesForPostType
24105 });
24106 }
24107
24108 ;// ./packages/editor/build-module/components/start-page-options/index.js
24109 /**
24110 * WordPress dependencies
24111 */
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123 /**
24124 * Internal dependencies
24125 */
24126
24127
24128
24129 function useStartPatterns() {
24130 // A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
24131 // and it has no postTypes declared and the current post type is page or if
24132 // the current post type is part of the postTypes declared.
24133 const {
24134 blockPatternsWithPostContentBlockType,
24135 postType
24136 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24137 const {
24138 getPatternsByBlockTypes,
24139 getBlocksByName
24140 } = select(external_wp_blockEditor_namespaceObject.store);
24141 const {
24142 getCurrentPostType,
24143 getRenderingMode
24144 } = select(store_store);
24145 const rootClientId = getRenderingMode() === 'post-only' ? '' : getBlocksByName('core/post-content')?.[0];
24146 return {
24147 blockPatternsWithPostContentBlockType: getPatternsByBlockTypes('core/post-content', rootClientId),
24148 postType: getCurrentPostType()
24149 };
24150 }, []);
24151 return (0,external_wp_element_namespaceObject.useMemo)(() => {
24152 if (!blockPatternsWithPostContentBlockType?.length) {
24153 return [];
24154 }
24155
24156 /*
24157 * Filter patterns without postTypes declared if the current postType is page
24158 * or patterns that declare the current postType in its post type array.
24159 */
24160 return blockPatternsWithPostContentBlockType.filter(pattern => {
24161 return postType === 'page' && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType);
24162 });
24163 }, [postType, blockPatternsWithPostContentBlockType]);
24164 }
24165 function PatternSelection({
24166 blockPatterns,
24167 onChoosePattern
24168 }) {
24169 const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns);
24170 const {
24171 editEntityRecord
24172 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
24173 const {
24174 postType,
24175 postId
24176 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24177 const {
24178 getCurrentPostType,
24179 getCurrentPostId
24180 } = select(store_store);
24181 return {
24182 postType: getCurrentPostType(),
24183 postId: getCurrentPostId()
24184 };
24185 }, []);
24186 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
24187 blockPatterns: blockPatterns,
24188 shownPatterns: shownBlockPatterns,
24189 onClickPattern: (_pattern, blocks) => {
24190 editEntityRecord('postType', postType, postId, {
24191 blocks,
24192 content: ({
24193 blocks: blocksForSerialization = []
24194 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization)
24195 });
24196 onChoosePattern();
24197 }
24198 });
24199 }
24200 function StartPageOptionsModal({
24201 onClose
24202 }) {
24203 const startPatterns = useStartPatterns();
24204 const hasStartPattern = startPatterns.length > 0;
24205 if (!hasStartPattern) {
24206 return null;
24207 }
24208 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
24209 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'),
24210 isFullScreen: true,
24211 onRequestClose: onClose,
24212 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24213 className: "editor-start-page-options__modal-content",
24214 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternSelection, {
24215 blockPatterns: startPatterns,
24216 onChoosePattern: onClose
24217 })
24218 })
24219 });
24220 }
24221 function StartPageOptions() {
24222 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false);
24223 const shouldEnableModal = (0,external_wp_data_namespaceObject.useSelect)(select => {
24224 const {
24225 isEditedPostDirty,
24226 isEditedPostEmpty,
24227 getCurrentPostType
24228 } = select(store_store);
24229 const preferencesModalActive = select(store).isModalActive('editor/preferences');
24230 const choosePatternModalEnabled = select(external_wp_preferences_namespaceObject.store).get('core', 'enableChoosePatternModal');
24231 return choosePatternModalEnabled && !preferencesModalActive && !isEditedPostDirty() && isEditedPostEmpty() && constants_TEMPLATE_POST_TYPE !== getCurrentPostType();
24232 }, []);
24233 if (!shouldEnableModal || isClosed) {
24234 return null;
24235 }
24236 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartPageOptionsModal, {
24237 onClose: () => setIsClosed(true)
24238 });
24239 }
24240
24241 ;// ./packages/editor/build-module/components/keyboard-shortcut-help-modal/config.js
24242 /**
24243 * WordPress dependencies
24244 */
24245
24246 const textFormattingShortcuts = [{
24247 keyCombination: {
24248 modifier: 'primary',
24249 character: 'b'
24250 },
24251 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
24252 }, {
24253 keyCombination: {
24254 modifier: 'primary',
24255 character: 'i'
24256 },
24257 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
24258 }, {
24259 keyCombination: {
24260 modifier: 'primary',
24261 character: 'k'
24262 },
24263 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
24264 }, {
24265 keyCombination: {
24266 modifier: 'primaryShift',
24267 character: 'k'
24268 },
24269 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
24270 }, {
24271 keyCombination: {
24272 character: '[['
24273 },
24274 description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page.')
24275 }, {
24276 keyCombination: {
24277 modifier: 'primary',
24278 character: 'u'
24279 },
24280 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
24281 }, {
24282 keyCombination: {
24283 modifier: 'access',
24284 character: 'd'
24285 },
24286 description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.')
24287 }, {
24288 keyCombination: {
24289 modifier: 'access',
24290 character: 'x'
24291 },
24292 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.')
24293 }, {
24294 keyCombination: {
24295 modifier: 'access',
24296 character: '0'
24297 },
24298 aliases: [{
24299 modifier: 'access',
24300 character: '7'
24301 }],
24302 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current heading to a paragraph.')
24303 }, {
24304 keyCombination: {
24305 modifier: 'access',
24306 character: '1-6'
24307 },
24308 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current paragraph or heading to a heading of level 1 to 6.')
24309 }, {
24310 keyCombination: {
24311 modifier: 'primaryShift',
24312 character: 'SPACE'
24313 },
24314 description: (0,external_wp_i18n_namespaceObject.__)('Add non breaking space.')
24315 }];
24316
24317 ;// ./packages/editor/build-module/components/keyboard-shortcut-help-modal/shortcut.js
24318 /**
24319 * WordPress dependencies
24320 */
24321
24322
24323
24324 function KeyCombination({
24325 keyCombination,
24326 forceAriaLabel
24327 }) {
24328 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
24329 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
24330 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
24331 className: "editor-keyboard-shortcut-help-modal__shortcut-key-combination",
24332 "aria-label": forceAriaLabel || ariaLabel,
24333 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => {
24334 if (character === '+') {
24335 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
24336 children: character
24337 }, index);
24338 }
24339 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
24340 className: "editor-keyboard-shortcut-help-modal__shortcut-key",
24341 children: character
24342 }, index);
24343 })
24344 });
24345 }
24346 function Shortcut({
24347 description,
24348 keyCombination,
24349 aliases = [],
24350 ariaLabel
24351 }) {
24352 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24353 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24354 className: "editor-keyboard-shortcut-help-modal__shortcut-description",
24355 children: description
24356 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24357 className: "editor-keyboard-shortcut-help-modal__shortcut-term",
24358 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
24359 keyCombination: keyCombination,
24360 forceAriaLabel: ariaLabel
24361 }), aliases.map((alias, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
24362 keyCombination: alias,
24363 forceAriaLabel: ariaLabel
24364 }, index))]
24365 })]
24366 });
24367 }
24368 /* harmony default export */ const keyboard_shortcut_help_modal_shortcut = (Shortcut);
24369
24370 ;// ./packages/editor/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
24371 /**
24372 * WordPress dependencies
24373 */
24374
24375
24376
24377 /**
24378 * Internal dependencies
24379 */
24380
24381
24382 function DynamicShortcut({
24383 name
24384 }) {
24385 const {
24386 keyCombination,
24387 description,
24388 aliases
24389 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24390 const {
24391 getShortcutKeyCombination,
24392 getShortcutDescription,
24393 getShortcutAliases
24394 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
24395 return {
24396 keyCombination: getShortcutKeyCombination(name),
24397 aliases: getShortcutAliases(name),
24398 description: getShortcutDescription(name)
24399 };
24400 }, [name]);
24401 if (!keyCombination) {
24402 return null;
24403 }
24404 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
24405 keyCombination: keyCombination,
24406 description: description,
24407 aliases: aliases
24408 });
24409 }
24410 /* harmony default export */ const dynamic_shortcut = (DynamicShortcut);
24411
24412 ;// ./packages/editor/build-module/components/keyboard-shortcut-help-modal/index.js
24413 /**
24414 * External dependencies
24415 */
24416
24417
24418 /**
24419 * WordPress dependencies
24420 */
24421
24422
24423
24424
24425
24426
24427 /**
24428 * Internal dependencies
24429 */
24430
24431
24432
24433
24434 const KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'editor/keyboard-shortcut-help';
24435 const ShortcutList = ({
24436 shortcuts
24437 }) =>
24438 /*#__PURE__*/
24439 /*
24440 * Disable reason: The `list` ARIA role is redundant but
24441 * Safari+VoiceOver won't announce the list otherwise.
24442 */
24443 /* eslint-disable jsx-a11y/no-redundant-roles */
24444 (0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
24445 className: "editor-keyboard-shortcut-help-modal__shortcut-list",
24446 role: "list",
24447 children: shortcuts.map((shortcut, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
24448 className: "editor-keyboard-shortcut-help-modal__shortcut",
24449 children: typeof shortcut === 'string' ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(dynamic_shortcut, {
24450 name: shortcut
24451 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
24452 ...shortcut
24453 })
24454 }, index))
24455 })
24456 /* eslint-enable jsx-a11y/no-redundant-roles */;
24457 const ShortcutSection = ({
24458 title,
24459 shortcuts,
24460 className
24461 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("section", {
24462 className: dist_clsx('editor-keyboard-shortcut-help-modal__section', className),
24463 children: [!!title && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
24464 className: "editor-keyboard-shortcut-help-modal__section-title",
24465 children: title
24466 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutList, {
24467 shortcuts: shortcuts
24468 })]
24469 });
24470 const ShortcutCategorySection = ({
24471 title,
24472 categoryName,
24473 additionalShortcuts = []
24474 }) => {
24475 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
24476 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
24477 }, [categoryName]);
24478 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
24479 title: title,
24480 shortcuts: categoryShortcuts.concat(additionalShortcuts)
24481 });
24482 };
24483 function KeyboardShortcutHelpModal() {
24484 const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(KEYBOARD_SHORTCUT_HELP_MODAL_NAME), []);
24485 const {
24486 openModal,
24487 closeModal
24488 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
24489 const toggleModal = () => {
24490 if (isModalActive) {
24491 closeModal();
24492 } else {
24493 openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
24494 }
24495 };
24496 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/keyboard-shortcuts', toggleModal);
24497 if (!isModalActive) {
24498 return null;
24499 }
24500 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
24501 className: "editor-keyboard-shortcut-help-modal",
24502 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
24503 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
24504 onRequestClose: toggleModal,
24505 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
24506 className: "editor-keyboard-shortcut-help-modal__main-shortcuts",
24507 shortcuts: ['core/editor/keyboard-shortcuts']
24508 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
24509 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
24510 categoryName: "global"
24511 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
24512 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
24513 categoryName: "selection"
24514 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
24515 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
24516 categoryName: "block",
24517 additionalShortcuts: [{
24518 keyCombination: {
24519 character: '/'
24520 },
24521 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
24522 /* translators: The forward-slash character. e.g. '/'. */
24523 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
24524 }]
24525 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
24526 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
24527 shortcuts: textFormattingShortcuts
24528 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
24529 title: (0,external_wp_i18n_namespaceObject.__)('List View shortcuts'),
24530 categoryName: "list-view"
24531 })]
24532 });
24533 }
24534 /* harmony default export */ const keyboard_shortcut_help_modal = (KeyboardShortcutHelpModal);
24535
24536 ;// ./packages/editor/build-module/components/block-settings-menu/content-only-settings-menu.js
24537 /**
24538 * WordPress dependencies
24539 */
24540
24541
24542
24543
24544
24545
24546 /**
24547 * Internal dependencies
24548 */
24549
24550
24551
24552
24553 function ContentOnlySettingsMenuItems({
24554 clientId,
24555 onClose
24556 }) {
24557 const postContentBlocks = usePostContentBlocks();
24558 const {
24559 entity,
24560 onNavigateToEntityRecord,
24561 canEditTemplates
24562 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24563 const {
24564 getBlockParentsByBlockName,
24565 getSettings,
24566 getBlockAttributes,
24567 getBlockParents
24568 } = select(external_wp_blockEditor_namespaceObject.store);
24569 const {
24570 getCurrentTemplateId,
24571 getRenderingMode
24572 } = select(store_store);
24573 const patternParent = getBlockParentsByBlockName(clientId, 'core/block', true)[0];
24574 let record;
24575 if (patternParent) {
24576 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', getBlockAttributes(patternParent).ref);
24577 } else if (getRenderingMode() === 'template-locked' && !getBlockParents(clientId).some(parent => postContentBlocks.includes(parent))) {
24578 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template', getCurrentTemplateId());
24579 }
24580 if (!record) {
24581 return {};
24582 }
24583 const _canEditTemplates = select(external_wp_coreData_namespaceObject.store).canUser('create', {
24584 kind: 'postType',
24585 name: 'wp_template'
24586 });
24587 return {
24588 canEditTemplates: _canEditTemplates,
24589 entity: record,
24590 onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
24591 };
24592 }, [clientId, postContentBlocks]);
24593 if (!entity) {
24594 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateLockContentOnlyMenuItems, {
24595 clientId: clientId,
24596 onClose: onClose
24597 });
24598 }
24599 const isPattern = entity.type === 'wp_block';
24600 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.');
24601 if (!canEditTemplates) {
24602 helpText = (0,external_wp_i18n_namespaceObject.__)('Only users with permissions to edit the template can move or delete this block');
24603 }
24604 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24605 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
24606 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
24607 onClick: () => {
24608 onNavigateToEntityRecord({
24609 postId: entity.id,
24610 postType: entity.type
24611 });
24612 },
24613 disabled: !canEditTemplates,
24614 children: isPattern ? (0,external_wp_i18n_namespaceObject.__)('Edit pattern') : (0,external_wp_i18n_namespaceObject.__)('Edit template')
24615 })
24616 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24617 variant: "muted",
24618 as: "p",
24619 className: "editor-content-only-settings-menu__description",
24620 children: helpText
24621 })]
24622 });
24623 }
24624 function TemplateLockContentOnlyMenuItems({
24625 clientId,
24626 onClose
24627 }) {
24628 const {
24629 contentLockingParent
24630 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24631 const {
24632 getContentLockingParent
24633 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
24634 return {
24635 contentLockingParent: getContentLockingParent(clientId)
24636 };
24637 }, [clientId]);
24638 const blockDisplayInformation = (0,external_wp_blockEditor_namespaceObject.useBlockDisplayInformation)(contentLockingParent);
24639 const blockEditorActions = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
24640 if (!blockDisplayInformation?.title) {
24641 return null;
24642 }
24643 const {
24644 modifyContentLockBlock
24645 } = unlock(blockEditorActions);
24646 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24647 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
24648 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
24649 onClick: () => {
24650 modifyContentLockBlock(contentLockingParent);
24651 onClose();
24652 },
24653 children: (0,external_wp_i18n_namespaceObject._x)('Unlock', 'Unlock content locked blocks')
24654 })
24655 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24656 variant: "muted",
24657 as: "p",
24658 className: "editor-content-only-settings-menu__description",
24659 children: (0,external_wp_i18n_namespaceObject.__)('Temporarily unlock the parent block to edit, delete or make further changes to this block.')
24660 })]
24661 });
24662 }
24663 function ContentOnlySettingsMenu() {
24664 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
24665 children: ({
24666 selectedClientIds,
24667 onClose
24668 }) => selectedClientIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ContentOnlySettingsMenuItems, {
24669 clientId: selectedClientIds[0],
24670 onClose: onClose
24671 })
24672 });
24673 }
24674
24675 ;// ./packages/editor/build-module/components/start-template-options/index.js
24676 /**
24677 * WordPress dependencies
24678 */
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688 /**
24689 * Internal dependencies
24690 */
24691
24692
24693
24694 function useFallbackTemplateContent(slug, isCustom = false) {
24695 return (0,external_wp_data_namespaceObject.useSelect)(select => {
24696 const {
24697 getEntityRecord,
24698 getDefaultTemplateId
24699 } = select(external_wp_coreData_namespaceObject.store);
24700 const templateId = getDefaultTemplateId({
24701 slug,
24702 is_custom: isCustom,
24703 ignore_empty: true
24704 });
24705 return templateId ? getEntityRecord('postType', constants_TEMPLATE_POST_TYPE, templateId)?.content?.raw : undefined;
24706 }, [slug, isCustom]);
24707 }
24708 function start_template_options_useStartPatterns(fallbackContent) {
24709 const {
24710 slug,
24711 patterns
24712 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24713 const {
24714 getCurrentPostType,
24715 getCurrentPostId
24716 } = select(store_store);
24717 const {
24718 getEntityRecord,
24719 getBlockPatterns
24720 } = select(external_wp_coreData_namespaceObject.store);
24721 const postId = getCurrentPostId();
24722 const postType = getCurrentPostType();
24723 const record = getEntityRecord('postType', postType, postId);
24724 return {
24725 slug: record.slug,
24726 patterns: getBlockPatterns()
24727 };
24728 }, []);
24729 const currentThemeStylesheet = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet);
24730
24731 // Duplicated from packages/block-library/src/pattern/edit.js.
24732 function injectThemeAttributeInBlockTemplateContent(block) {
24733 if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) {
24734 block.innerBlocks = block.innerBlocks.map(innerBlock => {
24735 if (innerBlock.name === 'core/template-part' && innerBlock.attributes.theme === undefined) {
24736 innerBlock.attributes.theme = currentThemeStylesheet;
24737 }
24738 return innerBlock;
24739 });
24740 }
24741 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
24742 block.attributes.theme = currentThemeStylesheet;
24743 }
24744 return block;
24745 }
24746 return (0,external_wp_element_namespaceObject.useMemo)(() => {
24747 // filter patterns that are supposed to be used in the current template being edited.
24748 return [{
24749 name: 'fallback',
24750 blocks: (0,external_wp_blocks_namespaceObject.parse)(fallbackContent),
24751 title: (0,external_wp_i18n_namespaceObject.__)('Fallback content')
24752 }, ...patterns.filter(pattern => {
24753 return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(templateType => slug.startsWith(templateType));
24754 }).map(pattern => {
24755 return {
24756 ...pattern,
24757 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content).map(block => injectThemeAttributeInBlockTemplateContent(block))
24758 };
24759 })];
24760 }, [fallbackContent, slug, patterns]);
24761 }
24762 function start_template_options_PatternSelection({
24763 fallbackContent,
24764 onChoosePattern,
24765 postType
24766 }) {
24767 const [,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', postType);
24768 const blockPatterns = start_template_options_useStartPatterns(fallbackContent);
24769 const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns);
24770 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
24771 blockPatterns: blockPatterns,
24772 shownPatterns: shownBlockPatterns,
24773 onClickPattern: (pattern, blocks) => {
24774 onChange(blocks, {
24775 selection: undefined
24776 });
24777 onChoosePattern();
24778 }
24779 });
24780 }
24781 function StartModal({
24782 slug,
24783 isCustom,
24784 onClose,
24785 postType
24786 }) {
24787 const fallbackContent = useFallbackTemplateContent(slug, isCustom);
24788 if (!fallbackContent) {
24789 return null;
24790 }
24791 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
24792 className: "editor-start-template-options__modal",
24793 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'),
24794 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Cancel'),
24795 focusOnMount: "firstElement",
24796 onRequestClose: onClose,
24797 isFullScreen: true,
24798 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24799 className: "editor-start-template-options__modal-content",
24800 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(start_template_options_PatternSelection, {
24801 fallbackContent: fallbackContent,
24802 slug: slug,
24803 isCustom: isCustom,
24804 postType: postType,
24805 onChoosePattern: () => {
24806 onClose();
24807 }
24808 })
24809 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
24810 className: "editor-start-template-options__modal__actions",
24811 justify: "flex-end",
24812 expanded: false,
24813 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
24814 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24815 __next40pxDefaultSize: true,
24816 variant: "tertiary",
24817 onClick: onClose,
24818 children: (0,external_wp_i18n_namespaceObject.__)('Skip')
24819 })
24820 })
24821 })]
24822 });
24823 }
24824 function StartTemplateOptions() {
24825 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false);
24826 const {
24827 shouldOpenModal,
24828 slug,
24829 isCustom,
24830 postType,
24831 postId
24832 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24833 const {
24834 getCurrentPostType,
24835 getCurrentPostId
24836 } = select(store_store);
24837 const _postType = getCurrentPostType();
24838 const _postId = getCurrentPostId();
24839 const {
24840 getEditedEntityRecord,
24841 hasEditsForEntityRecord
24842 } = select(external_wp_coreData_namespaceObject.store);
24843 const templateRecord = getEditedEntityRecord('postType', _postType, _postId);
24844 const hasEdits = hasEditsForEntityRecord('postType', _postType, _postId);
24845 return {
24846 shouldOpenModal: !hasEdits && '' === templateRecord.content && constants_TEMPLATE_POST_TYPE === _postType,
24847 slug: templateRecord.slug,
24848 isCustom: templateRecord.is_custom,
24849 postType: _postType,
24850 postId: _postId
24851 };
24852 }, []);
24853 (0,external_wp_element_namespaceObject.useEffect)(() => {
24854 // Should reset the modal state when navigating to a new page/post.
24855 setIsClosed(false);
24856 }, [postType, postId]);
24857 if (!shouldOpenModal || isClosed) {
24858 return null;
24859 }
24860 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartModal, {
24861 slug: slug,
24862 isCustom: isCustom,
24863 postType: postType,
24864 onClose: () => setIsClosed(true)
24865 });
24866 }
24867
24868 ;// ./packages/editor/build-module/components/template-part-menu-items/convert-to-regular.js
24869 /**
24870 * WordPress dependencies
24871 */
24872
24873
24874
24875
24876
24877 function ConvertToRegularBlocks({
24878 clientId,
24879 onClose
24880 }) {
24881 const {
24882 getBlocks
24883 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
24884 const {
24885 replaceBlocks
24886 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
24887 const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]);
24888 if (!canRemove) {
24889 return null;
24890 }
24891 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
24892 onClick: () => {
24893 replaceBlocks(clientId, getBlocks(clientId));
24894 onClose();
24895 },
24896 children: (0,external_wp_i18n_namespaceObject.__)('Detach')
24897 });
24898 }
24899
24900 ;// ./packages/editor/build-module/components/template-part-menu-items/convert-to-template-part.js
24901 /**
24902 * WordPress dependencies
24903 */
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913 /**
24914 * Internal dependencies
24915 */
24916
24917
24918 function ConvertToTemplatePart({
24919 clientIds,
24920 blocks
24921 }) {
24922 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
24923 const {
24924 replaceBlocks
24925 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
24926 const {
24927 createSuccessNotice
24928 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
24929 const {
24930 canCreate
24931 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24932 return {
24933 canCreate: select(external_wp_blockEditor_namespaceObject.store).canInsertBlockType('core/template-part')
24934 };
24935 }, []);
24936 if (!canCreate) {
24937 return null;
24938 }
24939 const onConvert = async templatePart => {
24940 replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', {
24941 slug: templatePart.slug,
24942 theme: templatePart.theme
24943 }));
24944 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), {
24945 type: 'snackbar'
24946 });
24947
24948 // The modal and this component will be unmounted because of `replaceBlocks` above,
24949 // so no need to call `closeModal` or `onClose`.
24950 };
24951 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24952 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
24953 icon: symbol_filled,
24954 onClick: () => {
24955 setIsModalOpen(true);
24956 },
24957 "aria-expanded": isModalOpen,
24958 "aria-haspopup": "dialog",
24959 children: (0,external_wp_i18n_namespaceObject.__)('Create template part')
24960 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModal, {
24961 closeModal: () => {
24962 setIsModalOpen(false);
24963 },
24964 blocks: blocks,
24965 onCreate: onConvert
24966 })]
24967 });
24968 }
24969
24970 ;// ./packages/editor/build-module/components/template-part-menu-items/index.js
24971 /**
24972 * WordPress dependencies
24973 */
24974
24975
24976
24977 /**
24978 * Internal dependencies
24979 */
24980
24981
24982
24983 function TemplatePartMenuItems() {
24984 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
24985 children: ({
24986 selectedClientIds,
24987 onClose
24988 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartConverterMenuItem, {
24989 clientIds: selectedClientIds,
24990 onClose: onClose
24991 })
24992 });
24993 }
24994 function TemplatePartConverterMenuItem({
24995 clientIds,
24996 onClose
24997 }) {
24998 const {
24999 isContentOnly,
25000 blocks
25001 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25002 const {
25003 getBlocksByClientId,
25004 getBlockEditingMode
25005 } = select(external_wp_blockEditor_namespaceObject.store);
25006 return {
25007 blocks: getBlocksByClientId(clientIds),
25008 isContentOnly: clientIds.length === 1 && getBlockEditingMode(clientIds[0]) === 'contentOnly'
25009 };
25010 }, [clientIds]);
25011
25012 // Do not show the convert button if the block is in content-only mode.
25013 if (isContentOnly) {
25014 return null;
25015 }
25016
25017 // Allow converting a single template part to standard blocks.
25018 if (blocks.length === 1 && blocks[0]?.name === 'core/template-part') {
25019 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConvertToRegularBlocks, {
25020 clientId: clientIds[0],
25021 onClose: onClose
25022 });
25023 }
25024 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConvertToTemplatePart, {
25025 clientIds: clientIds,
25026 blocks: blocks
25027 });
25028 }
25029
25030 ;// ./packages/editor/build-module/components/provider/index.js
25031 /**
25032 * WordPress dependencies
25033 */
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043 /**
25044 * Internal dependencies
25045 */
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064 const {
25065 ExperimentalBlockEditorProvider
25066 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
25067 const {
25068 PatternsMenuItems
25069 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25070 const provider_noop = () => {};
25071
25072 /**
25073 * These are global entities that are only there to split blocks into logical units
25074 * They don't provide a "context" for the current post/page being rendered.
25075 * So we should not use their ids as post context. This is important to allow post blocks
25076 * (post content, post title) to be used within them without issues.
25077 */
25078 const NON_CONTEXTUAL_POST_TYPES = ['wp_block', 'wp_navigation', 'wp_template_part'];
25079
25080 /**
25081 * Depending on the post, template and template mode,
25082 * returns the appropriate blocks and change handlers for the block editor provider.
25083 *
25084 * @param {Array} post Block list.
25085 * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.
25086 * @param {string} mode Rendering mode.
25087 *
25088 * @example
25089 * ```jsx
25090 * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );
25091 * ```
25092 *
25093 * @return {Array} Block editor props.
25094 */
25095 function useBlockEditorProps(post, template, mode) {
25096 const rootLevelPost = mode === 'post-only' || !template ? 'post' : 'template';
25097 const [postBlocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', post.type, {
25098 id: post.id
25099 });
25100 const [templateBlocks, onInputTemplate, onChangeTemplate] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', template?.type, {
25101 id: template?.id
25102 });
25103 const maybeNavigationBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
25104 if (post.type === 'wp_navigation') {
25105 return [(0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', {
25106 ref: post.id,
25107 // As the parent editor is locked with `templateLock`, the template locking
25108 // must be explicitly "unset" on the block itself to allow the user to modify
25109 // the block's content.
25110 templateLock: false
25111 })];
25112 }
25113 }, [post.type, post.id]);
25114
25115 // It is important that we don't create a new instance of blocks on every change
25116 // We should only create a new instance if the blocks them selves change, not a dependency of them.
25117 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
25118 if (maybeNavigationBlocks) {
25119 return maybeNavigationBlocks;
25120 }
25121 if (rootLevelPost === 'template') {
25122 return templateBlocks;
25123 }
25124 return postBlocks;
25125 }, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]);
25126
25127 // Handle fallback to postBlocks outside of the above useMemo, to ensure
25128 // that constructed block templates that call `createBlock` are not generated
25129 // too frequently. This ensures that clientIds are stable.
25130 const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation';
25131 if (disableRootLevelChanges) {
25132 return [blocks, provider_noop, provider_noop];
25133 }
25134 return [blocks, rootLevelPost === 'post' ? onInput : onInputTemplate, rootLevelPost === 'post' ? onChange : onChangeTemplate];
25135 }
25136
25137 /**
25138 * This component provides the editor context and manages the state of the block editor.
25139 *
25140 * @param {Object} props The component props.
25141 * @param {Object} props.post The post object.
25142 * @param {Object} props.settings The editor settings.
25143 * @param {boolean} props.recovery Indicates if the editor is in recovery mode.
25144 * @param {Array} props.initialEdits The initial edits for the editor.
25145 * @param {Object} props.children The child components.
25146 * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.
25147 * @param {Object} [props.__unstableTemplate] The template object.
25148 *
25149 * @example
25150 * ```jsx
25151 * <ExperimentalEditorProvider
25152 * post={ post }
25153 * settings={ settings }
25154 * recovery={ recovery }
25155 * initialEdits={ initialEdits }
25156 * __unstableTemplate={ template }
25157 * >
25158 * { children }
25159 * </ExperimentalEditorProvider>
25160 *
25161 * @return {Object} The rendered ExperimentalEditorProvider component.
25162 */
25163 const ExperimentalEditorProvider = with_registry_provider(({
25164 post,
25165 settings,
25166 recovery,
25167 initialEdits,
25168 children,
25169 BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
25170 __unstableTemplate: template
25171 }) => {
25172 const {
25173 editorSettings,
25174 selection,
25175 isReady,
25176 mode,
25177 postTypeEntities
25178 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25179 const {
25180 getEditorSettings,
25181 getEditorSelection,
25182 getRenderingMode,
25183 __unstableIsEditorReady
25184 } = select(store_store);
25185 const {
25186 getEntitiesConfig
25187 } = select(external_wp_coreData_namespaceObject.store);
25188 return {
25189 editorSettings: getEditorSettings(),
25190 isReady: __unstableIsEditorReady(),
25191 mode: getRenderingMode(),
25192 selection: getEditorSelection(),
25193 postTypeEntities: post.type === 'wp_template' ? getEntitiesConfig('postType') : null
25194 };
25195 }, [post.type]);
25196 const shouldRenderTemplate = !!template && mode !== 'post-only';
25197 const rootLevelPost = shouldRenderTemplate ? template : post;
25198 const defaultBlockContext = (0,external_wp_element_namespaceObject.useMemo)(() => {
25199 const postContext = {};
25200 // If it is a template, try to inherit the post type from the name.
25201 if (post.type === 'wp_template') {
25202 if (post.slug === 'page') {
25203 postContext.postType = 'page';
25204 } else if (post.slug === 'single') {
25205 postContext.postType = 'post';
25206 } else if (post.slug.split('-')[0] === 'single') {
25207 // If the slug is single-{postType}, infer the post type from the name.
25208 const postTypeNames = postTypeEntities?.map(entity => entity.name) || [];
25209 const match = post.slug.match(`^single-(${postTypeNames.join('|')})(?:-.+)?$`);
25210 if (match) {
25211 postContext.postType = match[1];
25212 }
25213 }
25214 } else if (!NON_CONTEXTUAL_POST_TYPES.includes(rootLevelPost.type) || shouldRenderTemplate) {
25215 postContext.postId = post.id;
25216 postContext.postType = post.type;
25217 }
25218 return {
25219 ...postContext,
25220 templateSlug: rootLevelPost.type === 'wp_template' ? rootLevelPost.slug : undefined
25221 };
25222 }, [shouldRenderTemplate, post.id, post.type, post.slug, rootLevelPost.type, rootLevelPost.slug, postTypeEntities]);
25223 const {
25224 id,
25225 type
25226 } = rootLevelPost;
25227 const blockEditorSettings = use_block_editor_settings(editorSettings, type, id, mode);
25228 const [blocks, onInput, onChange] = useBlockEditorProps(post, template, mode);
25229 const {
25230 updatePostLock,
25231 setupEditor,
25232 updateEditorSettings,
25233 setCurrentTemplateId,
25234 setEditedPost,
25235 setRenderingMode
25236 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
25237 const {
25238 createWarningNotice
25239 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25240
25241 // Ideally this should be synced on each change and not just something you do once.
25242 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
25243 // Assume that we don't need to initialize in the case of an error recovery.
25244 if (recovery) {
25245 return;
25246 }
25247 updatePostLock(settings.postLock);
25248 setupEditor(post, initialEdits, settings.template);
25249 if (settings.autosave) {
25250 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('There is an autosave of this post that is more recent than the version below.'), {
25251 id: 'autosave-exists',
25252 actions: [{
25253 label: (0,external_wp_i18n_namespaceObject.__)('View the autosave'),
25254 url: settings.autosave.editLink
25255 }]
25256 });
25257 }
25258 }, []);
25259
25260 // Synchronizes the active post with the state
25261 (0,external_wp_element_namespaceObject.useEffect)(() => {
25262 setEditedPost(post.type, post.id);
25263 }, [post.type, post.id, setEditedPost]);
25264
25265 // Synchronize the editor settings as they change.
25266 (0,external_wp_element_namespaceObject.useEffect)(() => {
25267 updateEditorSettings(settings);
25268 }, [settings, updateEditorSettings]);
25269
25270 // Synchronizes the active template with the state.
25271 (0,external_wp_element_namespaceObject.useEffect)(() => {
25272 setCurrentTemplateId(template?.id);
25273 }, [template?.id, setCurrentTemplateId]);
25274
25275 // Sets the right rendering mode when loading the editor.
25276 (0,external_wp_element_namespaceObject.useEffect)(() => {
25277 var _settings$defaultRend;
25278 setRenderingMode((_settings$defaultRend = settings.defaultRenderingMode) !== null && _settings$defaultRend !== void 0 ? _settings$defaultRend : 'post-only');
25279 }, [settings.defaultRenderingMode, setRenderingMode]);
25280 useHideBlocksFromInserter(post.type, mode);
25281
25282 // Register the editor commands.
25283 useCommands();
25284 if (!isReady) {
25285 return null;
25286 }
25287 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
25288 kind: "root",
25289 type: "site",
25290 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
25291 kind: "postType",
25292 type: post.type,
25293 id: post.id,
25294 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
25295 value: defaultBlockContext,
25296 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockEditorProviderComponent, {
25297 value: blocks,
25298 onChange: onChange,
25299 onInput: onInput,
25300 selection: selection,
25301 settings: blockEditorSettings,
25302 useSubRegistry: false,
25303 children: [children, !settings.isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25304 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, {})]
25305 })]
25306 })
25307 })
25308 })
25309 });
25310 });
25311
25312 /**
25313 * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).
25314 *
25315 * It supports a large number of post types, including post, page, templates,
25316 * custom post types, patterns, template parts.
25317 *
25318 * All modification and changes are performed to the `@wordpress/core-data` store.
25319 *
25320 * @param {Object} props The component props.
25321 * @param {Object} [props.post] The post object to edit. This is required.
25322 * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.
25323 * This is optional and can only be used when the post type supports templates (like posts and pages).
25324 * @param {Object} [props.settings] The settings object to use for the editor.
25325 * This is optional and can be used to override the default settings.
25326 * @param {Element} [props.children] Children elements for which the BlockEditorProvider context should apply.
25327 * This is optional.
25328 *
25329 * @example
25330 * ```jsx
25331 * <EditorProvider
25332 * post={ post }
25333 * settings={ settings }
25334 * __unstableTemplate={ template }
25335 * >
25336 * { children }
25337 * </EditorProvider>
25338 * ```
25339 *
25340 * @return {JSX.Element} The rendered EditorProvider component.
25341 */
25342 function EditorProvider(props) {
25343 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExperimentalEditorProvider, {
25344 ...props,
25345 BlockEditorProviderComponent: external_wp_blockEditor_namespaceObject.BlockEditorProvider,
25346 children: props.children
25347 });
25348 }
25349 /* harmony default export */ const provider = (EditorProvider);
25350
25351 ;// external ["wp","serverSideRender"]
25352 const external_wp_serverSideRender_namespaceObject = window["wp"]["serverSideRender"];
25353 var external_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_wp_serverSideRender_namespaceObject);
25354 ;// ./packages/editor/build-module/components/deprecated.js
25355 // Block Creation Components.
25356 /**
25357 * WordPress dependencies
25358 */
25359
25360
25361
25362
25363
25364 function deprecateComponent(name, Wrapped, staticsToHoist = []) {
25365 const Component = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
25366 external_wp_deprecated_default()('wp.editor.' + name, {
25367 since: '5.3',
25368 alternative: 'wp.blockEditor.' + name,
25369 version: '6.2'
25370 });
25371 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Wrapped, {
25372 ref: ref,
25373 ...props
25374 });
25375 });
25376 staticsToHoist.forEach(staticName => {
25377 Component[staticName] = deprecateComponent(name + '.' + staticName, Wrapped[staticName]);
25378 });
25379 return Component;
25380 }
25381 function deprecateFunction(name, func) {
25382 return (...args) => {
25383 external_wp_deprecated_default()('wp.editor.' + name, {
25384 since: '5.3',
25385 alternative: 'wp.blockEditor.' + name,
25386 version: '6.2'
25387 });
25388 return func(...args);
25389 };
25390 }
25391
25392 /**
25393 * @deprecated since 5.3, use `wp.blockEditor.RichText` instead.
25394 */
25395 const RichText = deprecateComponent('RichText', external_wp_blockEditor_namespaceObject.RichText, ['Content']);
25396 RichText.isEmpty = deprecateFunction('RichText.isEmpty', external_wp_blockEditor_namespaceObject.RichText.isEmpty);
25397
25398
25399 /**
25400 * @deprecated since 5.3, use `wp.blockEditor.Autocomplete` instead.
25401 */
25402 const Autocomplete = deprecateComponent('Autocomplete', external_wp_blockEditor_namespaceObject.Autocomplete);
25403 /**
25404 * @deprecated since 5.3, use `wp.blockEditor.AlignmentToolbar` instead.
25405 */
25406 const AlignmentToolbar = deprecateComponent('AlignmentToolbar', external_wp_blockEditor_namespaceObject.AlignmentToolbar);
25407 /**
25408 * @deprecated since 5.3, use `wp.blockEditor.BlockAlignmentToolbar` instead.
25409 */
25410 const BlockAlignmentToolbar = deprecateComponent('BlockAlignmentToolbar', external_wp_blockEditor_namespaceObject.BlockAlignmentToolbar);
25411 /**
25412 * @deprecated since 5.3, use `wp.blockEditor.BlockControls` instead.
25413 */
25414 const BlockControls = deprecateComponent('BlockControls', external_wp_blockEditor_namespaceObject.BlockControls, ['Slot']);
25415 /**
25416 * @deprecated since 5.3, use `wp.blockEditor.BlockEdit` instead.
25417 */
25418 const BlockEdit = deprecateComponent('BlockEdit', external_wp_blockEditor_namespaceObject.BlockEdit);
25419 /**
25420 * @deprecated since 5.3, use `wp.blockEditor.BlockEditorKeyboardShortcuts` instead.
25421 */
25422 const BlockEditorKeyboardShortcuts = deprecateComponent('BlockEditorKeyboardShortcuts', external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts);
25423 /**
25424 * @deprecated since 5.3, use `wp.blockEditor.BlockFormatControls` instead.
25425 */
25426 const BlockFormatControls = deprecateComponent('BlockFormatControls', external_wp_blockEditor_namespaceObject.BlockFormatControls, ['Slot']);
25427 /**
25428 * @deprecated since 5.3, use `wp.blockEditor.BlockIcon` instead.
25429 */
25430 const BlockIcon = deprecateComponent('BlockIcon', external_wp_blockEditor_namespaceObject.BlockIcon);
25431 /**
25432 * @deprecated since 5.3, use `wp.blockEditor.BlockInspector` instead.
25433 */
25434 const BlockInspector = deprecateComponent('BlockInspector', external_wp_blockEditor_namespaceObject.BlockInspector);
25435 /**
25436 * @deprecated since 5.3, use `wp.blockEditor.BlockList` instead.
25437 */
25438 const BlockList = deprecateComponent('BlockList', external_wp_blockEditor_namespaceObject.BlockList);
25439 /**
25440 * @deprecated since 5.3, use `wp.blockEditor.BlockMover` instead.
25441 */
25442 const BlockMover = deprecateComponent('BlockMover', external_wp_blockEditor_namespaceObject.BlockMover);
25443 /**
25444 * @deprecated since 5.3, use `wp.blockEditor.BlockNavigationDropdown` instead.
25445 */
25446 const BlockNavigationDropdown = deprecateComponent('BlockNavigationDropdown', external_wp_blockEditor_namespaceObject.BlockNavigationDropdown);
25447 /**
25448 * @deprecated since 5.3, use `wp.blockEditor.BlockSelectionClearer` instead.
25449 */
25450 const BlockSelectionClearer = deprecateComponent('BlockSelectionClearer', external_wp_blockEditor_namespaceObject.BlockSelectionClearer);
25451 /**
25452 * @deprecated since 5.3, use `wp.blockEditor.BlockSettingsMenu` instead.
25453 */
25454 const BlockSettingsMenu = deprecateComponent('BlockSettingsMenu', external_wp_blockEditor_namespaceObject.BlockSettingsMenu);
25455 /**
25456 * @deprecated since 5.3, use `wp.blockEditor.BlockTitle` instead.
25457 */
25458 const BlockTitle = deprecateComponent('BlockTitle', external_wp_blockEditor_namespaceObject.BlockTitle);
25459 /**
25460 * @deprecated since 5.3, use `wp.blockEditor.BlockToolbar` instead.
25461 */
25462 const BlockToolbar = deprecateComponent('BlockToolbar', external_wp_blockEditor_namespaceObject.BlockToolbar);
25463 /**
25464 * @deprecated since 5.3, use `wp.blockEditor.ColorPalette` instead.
25465 */
25466 const ColorPalette = deprecateComponent('ColorPalette', external_wp_blockEditor_namespaceObject.ColorPalette);
25467 /**
25468 * @deprecated since 5.3, use `wp.blockEditor.ContrastChecker` instead.
25469 */
25470 const ContrastChecker = deprecateComponent('ContrastChecker', external_wp_blockEditor_namespaceObject.ContrastChecker);
25471 /**
25472 * @deprecated since 5.3, use `wp.blockEditor.CopyHandler` instead.
25473 */
25474 const CopyHandler = deprecateComponent('CopyHandler', external_wp_blockEditor_namespaceObject.CopyHandler);
25475 /**
25476 * @deprecated since 5.3, use `wp.blockEditor.DefaultBlockAppender` instead.
25477 */
25478 const DefaultBlockAppender = deprecateComponent('DefaultBlockAppender', external_wp_blockEditor_namespaceObject.DefaultBlockAppender);
25479 /**
25480 * @deprecated since 5.3, use `wp.blockEditor.FontSizePicker` instead.
25481 */
25482 const FontSizePicker = deprecateComponent('FontSizePicker', external_wp_blockEditor_namespaceObject.FontSizePicker);
25483 /**
25484 * @deprecated since 5.3, use `wp.blockEditor.Inserter` instead.
25485 */
25486 const Inserter = deprecateComponent('Inserter', external_wp_blockEditor_namespaceObject.Inserter);
25487 /**
25488 * @deprecated since 5.3, use `wp.blockEditor.InnerBlocks` instead.
25489 */
25490 const InnerBlocks = deprecateComponent('InnerBlocks', external_wp_blockEditor_namespaceObject.InnerBlocks, ['ButtonBlockAppender', 'DefaultBlockAppender', 'Content']);
25491 /**
25492 * @deprecated since 5.3, use `wp.blockEditor.InspectorAdvancedControls` instead.
25493 */
25494 const InspectorAdvancedControls = deprecateComponent('InspectorAdvancedControls', external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, ['Slot']);
25495 /**
25496 * @deprecated since 5.3, use `wp.blockEditor.InspectorControls` instead.
25497 */
25498 const InspectorControls = deprecateComponent('InspectorControls', external_wp_blockEditor_namespaceObject.InspectorControls, ['Slot']);
25499 /**
25500 * @deprecated since 5.3, use `wp.blockEditor.PanelColorSettings` instead.
25501 */
25502 const PanelColorSettings = deprecateComponent('PanelColorSettings', external_wp_blockEditor_namespaceObject.PanelColorSettings);
25503 /**
25504 * @deprecated since 5.3, use `wp.blockEditor.PlainText` instead.
25505 */
25506 const PlainText = deprecateComponent('PlainText', external_wp_blockEditor_namespaceObject.PlainText);
25507 /**
25508 * @deprecated since 5.3, use `wp.blockEditor.RichTextShortcut` instead.
25509 */
25510 const RichTextShortcut = deprecateComponent('RichTextShortcut', external_wp_blockEditor_namespaceObject.RichTextShortcut);
25511 /**
25512 * @deprecated since 5.3, use `wp.blockEditor.RichTextToolbarButton` instead.
25513 */
25514 const RichTextToolbarButton = deprecateComponent('RichTextToolbarButton', external_wp_blockEditor_namespaceObject.RichTextToolbarButton);
25515 /**
25516 * @deprecated since 5.3, use `wp.blockEditor.__unstableRichTextInputEvent` instead.
25517 */
25518 const __unstableRichTextInputEvent = deprecateComponent('__unstableRichTextInputEvent', external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent);
25519 /**
25520 * @deprecated since 5.3, use `wp.blockEditor.MediaPlaceholder` instead.
25521 */
25522 const MediaPlaceholder = deprecateComponent('MediaPlaceholder', external_wp_blockEditor_namespaceObject.MediaPlaceholder);
25523 /**
25524 * @deprecated since 5.3, use `wp.blockEditor.MediaUpload` instead.
25525 */
25526 const MediaUpload = deprecateComponent('MediaUpload', external_wp_blockEditor_namespaceObject.MediaUpload);
25527 /**
25528 * @deprecated since 5.3, use `wp.blockEditor.MediaUploadCheck` instead.
25529 */
25530 const MediaUploadCheck = deprecateComponent('MediaUploadCheck', external_wp_blockEditor_namespaceObject.MediaUploadCheck);
25531 /**
25532 * @deprecated since 5.3, use `wp.blockEditor.MultiSelectScrollIntoView` instead.
25533 */
25534 const MultiSelectScrollIntoView = deprecateComponent('MultiSelectScrollIntoView', external_wp_blockEditor_namespaceObject.MultiSelectScrollIntoView);
25535 /**
25536 * @deprecated since 5.3, use `wp.blockEditor.NavigableToolbar` instead.
25537 */
25538 const NavigableToolbar = deprecateComponent('NavigableToolbar', external_wp_blockEditor_namespaceObject.NavigableToolbar);
25539 /**
25540 * @deprecated since 5.3, use `wp.blockEditor.ObserveTyping` instead.
25541 */
25542 const ObserveTyping = deprecateComponent('ObserveTyping', external_wp_blockEditor_namespaceObject.ObserveTyping);
25543 /**
25544 * @deprecated since 5.3, use `wp.blockEditor.SkipToSelectedBlock` instead.
25545 */
25546 const SkipToSelectedBlock = deprecateComponent('SkipToSelectedBlock', external_wp_blockEditor_namespaceObject.SkipToSelectedBlock);
25547 /**
25548 * @deprecated since 5.3, use `wp.blockEditor.URLInput` instead.
25549 */
25550 const URLInput = deprecateComponent('URLInput', external_wp_blockEditor_namespaceObject.URLInput);
25551 /**
25552 * @deprecated since 5.3, use `wp.blockEditor.URLInputButton` instead.
25553 */
25554 const URLInputButton = deprecateComponent('URLInputButton', external_wp_blockEditor_namespaceObject.URLInputButton);
25555 /**
25556 * @deprecated since 5.3, use `wp.blockEditor.URLPopover` instead.
25557 */
25558 const URLPopover = deprecateComponent('URLPopover', external_wp_blockEditor_namespaceObject.URLPopover);
25559 /**
25560 * @deprecated since 5.3, use `wp.blockEditor.Warning` instead.
25561 */
25562 const Warning = deprecateComponent('Warning', external_wp_blockEditor_namespaceObject.Warning);
25563 /**
25564 * @deprecated since 5.3, use `wp.blockEditor.WritingFlow` instead.
25565 */
25566 const WritingFlow = deprecateComponent('WritingFlow', external_wp_blockEditor_namespaceObject.WritingFlow);
25567
25568 /**
25569 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
25570 */
25571 const createCustomColorsHOC = deprecateFunction('createCustomColorsHOC', external_wp_blockEditor_namespaceObject.createCustomColorsHOC);
25572 /**
25573 * @deprecated since 5.3, use `wp.blockEditor.getColorClassName` instead.
25574 */
25575 const getColorClassName = deprecateFunction('getColorClassName', external_wp_blockEditor_namespaceObject.getColorClassName);
25576 /**
25577 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByAttributeValues` instead.
25578 */
25579 const getColorObjectByAttributeValues = deprecateFunction('getColorObjectByAttributeValues', external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues);
25580 /**
25581 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByColorValue` instead.
25582 */
25583 const getColorObjectByColorValue = deprecateFunction('getColorObjectByColorValue', external_wp_blockEditor_namespaceObject.getColorObjectByColorValue);
25584 /**
25585 * @deprecated since 5.3, use `wp.blockEditor.getFontSize` instead.
25586 */
25587 const getFontSize = deprecateFunction('getFontSize', external_wp_blockEditor_namespaceObject.getFontSize);
25588 /**
25589 * @deprecated since 5.3, use `wp.blockEditor.getFontSizeClass` instead.
25590 */
25591 const getFontSizeClass = deprecateFunction('getFontSizeClass', external_wp_blockEditor_namespaceObject.getFontSizeClass);
25592 /**
25593 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
25594 */
25595 const withColorContext = deprecateFunction('withColorContext', external_wp_blockEditor_namespaceObject.withColorContext);
25596 /**
25597 * @deprecated since 5.3, use `wp.blockEditor.withColors` instead.
25598 */
25599 const withColors = deprecateFunction('withColors', external_wp_blockEditor_namespaceObject.withColors);
25600 /**
25601 * @deprecated since 5.3, use `wp.blockEditor.withFontSizes` instead.
25602 */
25603 const withFontSizes = deprecateFunction('withFontSizes', external_wp_blockEditor_namespaceObject.withFontSizes);
25604
25605 ;// ./packages/editor/build-module/components/index.js
25606 /**
25607 * Internal dependencies
25608 */
25609
25610
25611 // Block Creation Components.
25612
25613
25614 // Post Related Components.
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704 // State Related Components.
25705
25706
25707
25708 /**
25709 * Handles the keyboard shortcuts for the editor.
25710 *
25711 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
25712 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
25713 * and toggling the sidebar.
25714 */
25715 const VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
25716
25717 /**
25718 * Handles the keyboard shortcuts for the editor.
25719 *
25720 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
25721 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
25722 * and toggling the sidebar.
25723 */
25724 const TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
25725
25726 ;// ./packages/editor/build-module/utils/url.js
25727 /**
25728 * WordPress dependencies
25729 */
25730
25731
25732
25733 /**
25734 * Performs some basic cleanup of a string for use as a post slug
25735 *
25736 * This replicates some of what sanitize_title() does in WordPress core, but
25737 * is only designed to approximate what the slug will be.
25738 *
25739 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters.
25740 * Removes combining diacritical marks. Converts whitespace, periods,
25741 * and forward slashes to hyphens. Removes any remaining non-word characters
25742 * except hyphens and underscores. Converts remaining string to lowercase.
25743 * It does not account for octets, HTML entities, or other encoded characters.
25744 *
25745 * @param {string} string Title or slug to be processed
25746 *
25747 * @return {string} Processed string
25748 */
25749 function cleanForSlug(string) {
25750 external_wp_deprecated_default()('wp.editor.cleanForSlug', {
25751 since: '12.7',
25752 plugin: 'Gutenberg',
25753 alternative: 'wp.url.cleanForSlug'
25754 });
25755 return (0,external_wp_url_namespaceObject.cleanForSlug)(string);
25756 }
25757
25758 ;// ./packages/editor/build-module/utils/index.js
25759 /**
25760 * Internal dependencies
25761 */
25762
25763
25764
25765
25766
25767 ;// ./packages/editor/build-module/components/editor-interface/content-slot-fill.js
25768 /**
25769 * WordPress dependencies
25770 */
25771
25772
25773 /**
25774 * Internal dependencies
25775 */
25776
25777 const {
25778 createPrivateSlotFill
25779 } = unlock(external_wp_components_namespaceObject.privateApis);
25780 const SLOT_FILL_NAME = 'EditCanvasContainerSlot';
25781 const EditorContentSlotFill = createPrivateSlotFill(SLOT_FILL_NAME);
25782 /* harmony default export */ const content_slot_fill = (EditorContentSlotFill);
25783
25784 ;// ./packages/editor/build-module/components/header/back-button.js
25785 /**
25786 * WordPress dependencies
25787 */
25788
25789
25790 // Keeping an old name for backward compatibility.
25791
25792 const slotName = '__experimentalMainDashboardButton';
25793 const useHasBackButton = () => {
25794 const fills = (0,external_wp_components_namespaceObject.__experimentalUseSlotFills)(slotName);
25795 return Boolean(fills && fills.length);
25796 };
25797 const {
25798 Fill: back_button_Fill,
25799 Slot: back_button_Slot
25800 } = (0,external_wp_components_namespaceObject.createSlotFill)(slotName);
25801 const BackButton = back_button_Fill;
25802 const BackButtonSlot = () => {
25803 const fills = (0,external_wp_components_namespaceObject.__experimentalUseSlotFills)(slotName);
25804 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button_Slot, {
25805 bubblesVirtually: true,
25806 fillProps: {
25807 length: !fills ? 0 : fills.length
25808 }
25809 });
25810 };
25811 BackButton.Slot = BackButtonSlot;
25812 /* harmony default export */ const back_button = (BackButton);
25813
25814 ;// ./packages/icons/build-module/library/comment.js
25815 /**
25816 * WordPress dependencies
25817 */
25818
25819
25820 const comment = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25821 viewBox: "0 0 24 24",
25822 xmlns: "http://www.w3.org/2000/svg",
25823 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25824 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"
25825 })
25826 });
25827 /* harmony default export */ const library_comment = (comment);
25828
25829 ;// ./packages/editor/build-module/components/collab-sidebar/constants.js
25830 const collabSidebarName = 'edit-post/collab-sidebar';
25831
25832 ;// ./packages/icons/build-module/library/more-vertical.js
25833 /**
25834 * WordPress dependencies
25835 */
25836
25837
25838 const moreVertical = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25839 xmlns: "http://www.w3.org/2000/svg",
25840 viewBox: "0 0 24 24",
25841 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25842 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
25843 })
25844 });
25845 /* harmony default export */ const more_vertical = (moreVertical);
25846
25847 ;// ./packages/editor/build-module/components/collab-sidebar/utils.js
25848 /**
25849 * Sanitizes a comment string by removing non-printable ASCII characters.
25850 *
25851 * @param {string} str - The comment string to sanitize.
25852 * @return {string} - The sanitized comment string.
25853 */
25854 function sanitizeCommentString(str) {
25855 return str.trim();
25856 }
25857
25858 ;// ./packages/editor/build-module/components/collab-sidebar/comments.js
25859 /**
25860 * External dependencies
25861 */
25862
25863
25864 /**
25865 * WordPress dependencies
25866 */
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876 /**
25877 * Internal dependencies
25878 */
25879
25880
25881 /**
25882 * Renders the Comments component.
25883 *
25884 * @param {Object} props - The component props.
25885 * @param {Array} props.threads - The array of comment threads.
25886 * @param {Function} props.onEditComment - The function to handle comment editing.
25887 * @param {Function} props.onAddReply - The function to add a reply to a comment.
25888 * @param {Function} props.onCommentDelete - The function to delete a comment.
25889 * @param {Function} props.onCommentResolve - The function to mark a comment as resolved.
25890 * @return {JSX.Element} The rendered Comments component.
25891 */
25892
25893 function Comments({
25894 threads,
25895 onEditComment,
25896 onAddReply,
25897 onCommentDelete,
25898 onCommentResolve
25899 }) {
25900 const [actionState, setActionState] = (0,external_wp_element_namespaceObject.useState)(false);
25901 const [isConfirmDialogOpen, setIsConfirmDialogOpen] = (0,external_wp_element_namespaceObject.useState)(false);
25902 const handleConfirmDelete = () => {
25903 onCommentDelete(actionState.id);
25904 setActionState(false);
25905 setIsConfirmDialogOpen(false);
25906 };
25907 const handleConfirmResolve = () => {
25908 onCommentResolve(actionState.id);
25909 setActionState(false);
25910 setIsConfirmDialogOpen(false);
25911 };
25912 const handleCancelDelete = () => {
25913 setActionState(false);
25914 setIsConfirmDialogOpen(false);
25915 };
25916 const blockCommentId = (0,external_wp_data_namespaceObject.useSelect)(select => {
25917 var _select$getBlock$attr;
25918 const clientID = select(external_wp_blockEditor_namespaceObject.store).getSelectedBlockClientId();
25919 return (_select$getBlock$attr = select(external_wp_blockEditor_namespaceObject.store).getBlock(clientID)?.attributes?.blockCommentId) !== null && _select$getBlock$attr !== void 0 ? _select$getBlock$attr : false;
25920 }, []);
25921 const CommentBoard = ({
25922 thread,
25923 parentThread
25924 }) => {
25925 var _parentThread$status;
25926 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25927 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentHeader, {
25928 thread: thread,
25929 onResolve: () => {
25930 var _parentThread$id;
25931 setActionState({
25932 action: 'resolve',
25933 id: (_parentThread$id = parentThread?.id) !== null && _parentThread$id !== void 0 ? _parentThread$id : thread.id
25934 });
25935 setIsConfirmDialogOpen(true);
25936 },
25937 onEdit: () => setActionState({
25938 action: 'edit',
25939 id: thread.id
25940 }),
25941 onDelete: () => {
25942 setActionState({
25943 action: 'delete',
25944 id: thread.id
25945 });
25946 setIsConfirmDialogOpen(true);
25947 },
25948 onReply: !parentThread ? () => setActionState({
25949 action: 'reply',
25950 id: thread.id
25951 }) : undefined,
25952 status: (_parentThread$status = parentThread?.status) !== null && _parentThread$status !== void 0 ? _parentThread$status : thread.status
25953 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHStack, {
25954 alignment: "left",
25955 spacing: "3",
25956 justify: "flex-start",
25957 className: "editor-collab-sidebar-panel__user-comment",
25958 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
25959 spacing: "3",
25960 className: "editor-collab-sidebar-panel__comment-field",
25961 children: ['edit' === actionState?.action && thread.id === actionState?.id && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentForm, {
25962 onSubmit: value => {
25963 onEditComment(thread.id, value);
25964 setActionState(false);
25965 },
25966 onCancel: () => setActionState(false),
25967 thread: thread
25968 }), (!actionState || 'edit' !== actionState?.action) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.RawHTML, {
25969 children: thread?.content?.raw
25970 })]
25971 })
25972 }), 'resolve' === actionState?.action && thread.id === actionState?.id && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
25973 isOpen: isConfirmDialogOpen,
25974 onConfirm: handleConfirmResolve,
25975 onCancel: handleCancelDelete,
25976 confirmButtonText: "Yes",
25977 cancelButtonText: "No",
25978 children:
25979 // translators: message displayed when confirming an action
25980 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to mark this comment as resolved?')
25981 }), 'delete' === actionState?.action && thread.id === actionState?.id && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
25982 isOpen: isConfirmDialogOpen,
25983 onConfirm: handleConfirmDelete,
25984 onCancel: handleCancelDelete,
25985 confirmButtonText: "Yes",
25986 cancelButtonText: "No",
25987 children:
25988 // translators: message displayed when confirming an action
25989 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete this comment?')
25990 })]
25991 });
25992 };
25993 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25994 children: [
25995 // If there are no comments, show a message indicating no comments are available.
25996 (!Array.isArray(threads) || threads.length === 0) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
25997 alignment: "left",
25998 className: "editor-collab-sidebar-panel__thread",
25999 justify: "flex-start",
26000 spacing: "3",
26001 children:
26002 // translators: message displayed when there are no comments available
26003 (0,external_wp_i18n_namespaceObject.__)('No comments available')
26004 }), Array.isArray(threads) && threads.length > 0 && threads.map(thread => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26005 className: dist_clsx('editor-collab-sidebar-panel__thread', {
26006 'editor-collab-sidebar-panel__active-thread': blockCommentId && blockCommentId === thread.id
26007 }),
26008 id: thread.id,
26009 spacing: "3",
26010 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentBoard, {
26011 thread: thread
26012 }), 'reply' === actionState?.action && thread.id === actionState?.id && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHStack, {
26013 alignment: "left",
26014 spacing: "3",
26015 justify: "flex-start",
26016 className: "editor-collab-sidebar-panel__user-comment",
26017 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
26018 spacing: "3",
26019 className: "editor-collab-sidebar-panel__comment-field",
26020 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentForm, {
26021 onSubmit: inputComment => {
26022 onAddReply(inputComment, thread.id);
26023 setActionState(false);
26024 },
26025 onCancel: () => setActionState(false)
26026 })
26027 })
26028 }), 0 < thread?.reply?.length && thread.reply.map(reply => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
26029 className: "editor-collab-sidebar-panel__child-thread",
26030 id: reply.id,
26031 spacing: "2",
26032 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentBoard, {
26033 thread: reply,
26034 parentThread: thread
26035 })
26036 }, reply.id))]
26037 }, thread.id))]
26038 });
26039 }
26040
26041 /**
26042 * EditComment component.
26043 *
26044 * @param {Object} props - The component props.
26045 * @param {Function} props.onSubmit - The function to call when updating the comment.
26046 * @param {Function} props.onCancel - The function to call when canceling the comment update.
26047 * @param {Object} props.thread - The comment thread object.
26048 * @return {JSX.Element} The CommentForm component.
26049 */
26050 function CommentForm({
26051 onSubmit,
26052 onCancel,
26053 thread
26054 }) {
26055 var _thread$content$raw;
26056 const [inputComment, setInputComment] = (0,external_wp_element_namespaceObject.useState)((_thread$content$raw = thread?.content?.raw) !== null && _thread$content$raw !== void 0 ? _thread$content$raw : '');
26057 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26058 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
26059 __nextHasNoMarginBottom: true,
26060 value: inputComment !== null && inputComment !== void 0 ? inputComment : '',
26061 onChange: setInputComment
26062 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
26063 alignment: "left",
26064 spacing: "3",
26065 justify: "flex-start",
26066 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26067 alignment: "left",
26068 spacing: "3",
26069 justify: "flex-start",
26070 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26071 __next40pxDefaultSize: true,
26072 accessibleWhenDisabled: true,
26073 variant: "primary",
26074 onClick: () => onSubmit(inputComment),
26075 disabled: 0 === sanitizeCommentString(inputComment).length,
26076 children: thread ? (0,external_wp_i18n_namespaceObject._x)('Update', 'verb') : (0,external_wp_i18n_namespaceObject._x)('Reply', 'Add reply comment')
26077 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26078 __next40pxDefaultSize: true,
26079 onClick: onCancel,
26080 children: (0,external_wp_i18n_namespaceObject._x)('Cancel', 'Cancel comment edit')
26081 })]
26082 })
26083 })]
26084 });
26085 }
26086
26087 /**
26088 * Renders the header of a comment in the collaboration sidebar.
26089 *
26090 * @param {Object} props - The component props.
26091 * @param {Object} props.thread - The comment thread object.
26092 * @param {Function} props.onResolve - The function to resolve the comment.
26093 * @param {Function} props.onEdit - The function to edit the comment.
26094 * @param {Function} props.onDelete - The function to delete the comment.
26095 * @param {Function} props.onReply - The function to reply to the comment.
26096 * @param {string} props.status - The status of the comment.
26097 * @return {JSX.Element} The rendered comment header.
26098 */
26099 function CommentHeader({
26100 thread,
26101 onResolve,
26102 onEdit,
26103 onDelete,
26104 onReply,
26105 status
26106 }) {
26107 const dateSettings = (0,external_wp_date_namespaceObject.getSettings)();
26108 const [dateTimeFormat = dateSettings.formats.time] = (0,external_wp_coreData_namespaceObject.useEntityProp)('root', 'site', 'time_format');
26109 const actions = [{
26110 title: (0,external_wp_i18n_namespaceObject._x)('Edit', 'Edit comment'),
26111 onClick: onEdit
26112 }, {
26113 title: (0,external_wp_i18n_namespaceObject._x)('Delete', 'Delete comment'),
26114 onClick: onDelete
26115 }, {
26116 title: (0,external_wp_i18n_namespaceObject._x)('Reply', 'Reply on a comment'),
26117 onClick: onReply
26118 }];
26119 const moreActions = actions.filter(item => item.onClick);
26120 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26121 alignment: "left",
26122 spacing: "3",
26123 justify: "flex-start",
26124 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
26125 src: thread?.author_avatar_urls?.[48],
26126 className: "editor-collab-sidebar-panel__user-avatar"
26127 // translators: alt text for user avatar image
26128 ,
26129 alt: (0,external_wp_i18n_namespaceObject.__)('User avatar'),
26130 width: 32,
26131 height: 32
26132 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26133 spacing: "0",
26134 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
26135 className: "editor-collab-sidebar-panel__user-name",
26136 children: thread.author_name
26137 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("time", {
26138 dateTime: (0,external_wp_date_namespaceObject.format)('h:i A', thread.date),
26139 className: "editor-collab-sidebar-panel__user-time",
26140 children: (0,external_wp_date_namespaceObject.dateI18n)(dateTimeFormat, thread.date)
26141 })]
26142 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("span", {
26143 className: "editor-collab-sidebar-panel__comment-status",
26144 children: [status !== 'approved' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26145 alignment: "right",
26146 justify: "flex-end",
26147 spacing: "0",
26148 children: [0 === thread.parent && onResolve && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26149 label: (0,external_wp_i18n_namespaceObject._x)('Resolve', 'Mark comment as resolved'),
26150 __next40pxDefaultSize: true,
26151 icon: library_published,
26152 onClick: onResolve,
26153 showTooltip: true
26154 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
26155 icon: more_vertical,
26156 label: (0,external_wp_i18n_namespaceObject._x)('Select an action', 'Select comment action'),
26157 className: "editor-collab-sidebar-panel__comment-dropdown-menu",
26158 controls: moreActions
26159 })]
26160 }), status === 'approved' &&
26161 /*#__PURE__*/
26162 // translators: tooltip for resolved comment
26163 (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Tooltip, {
26164 text: (0,external_wp_i18n_namespaceObject.__)('Resolved'),
26165 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
26166 icon: library_check
26167 })
26168 })]
26169 })]
26170 });
26171 }
26172
26173 ;// ./packages/editor/build-module/components/collab-sidebar/add-comment.js
26174 /**
26175 * WordPress dependencies
26176 */
26177
26178
26179
26180
26181
26182
26183
26184 /**
26185 * Internal dependencies
26186 */
26187
26188
26189 /**
26190 * Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.
26191 *
26192 * @param {Object} props - The component props.
26193 * @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.
26194 * @param {boolean} props.showCommentBoard - The function to edit the comment.
26195 * @param {Function} props.setShowCommentBoard - The function to delete the comment.
26196 * @return {JSX.Element} The rendered comment input UI.
26197 */
26198
26199 function AddComment({
26200 onSubmit,
26201 showCommentBoard,
26202 setShowCommentBoard
26203 }) {
26204 var _currentUser$name;
26205 // State to manage the comment thread.
26206 const [inputComment, setInputComment] = (0,external_wp_element_namespaceObject.useState)('');
26207 const {
26208 defaultAvatar,
26209 clientId,
26210 blockCommentId,
26211 showAddCommentBoard,
26212 currentUser
26213 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26214 const {
26215 getSettings
26216 } = select(external_wp_blockEditor_namespaceObject.store);
26217 const {
26218 __experimentalDiscussionSettings
26219 } = getSettings();
26220 const selectedBlock = select(external_wp_blockEditor_namespaceObject.store).getSelectedBlock();
26221 const userData = select(external_wp_coreData_namespaceObject.store).getCurrentUser();
26222 return {
26223 defaultAvatar: __experimentalDiscussionSettings?.avatarURL,
26224 clientId: selectedBlock?.clientId,
26225 blockCommentId: selectedBlock?.attributes?.blockCommentId,
26226 showAddCommentBoard: showCommentBoard,
26227 currentUser: userData
26228 };
26229 });
26230 const userAvatar = currentUser && currentUser.avatar_urls && currentUser.avatar_urls[48] ? currentUser.avatar_urls[48] : defaultAvatar;
26231 (0,external_wp_element_namespaceObject.useEffect)(() => {
26232 setInputComment('');
26233 }, [clientId]);
26234 const handleCancel = () => {
26235 setShowCommentBoard(false);
26236 setInputComment('');
26237 };
26238 if (!showAddCommentBoard || !clientId || undefined !== blockCommentId) {
26239 return null;
26240 }
26241 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26242 spacing: "3",
26243 className: "editor-collab-sidebar-panel__thread editor-collab-sidebar-panel__active-thread",
26244 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26245 alignment: "left",
26246 spacing: "3",
26247 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
26248 src: userAvatar
26249 // translators: alt text for user avatar image
26250 ,
26251 alt: (0,external_wp_i18n_namespaceObject.__)('User Avatar'),
26252 className: "editor-collab-sidebar-panel__user-avatar",
26253 width: 32,
26254 height: 32
26255 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
26256 className: "editor-collab-sidebar-panel__user-name",
26257 children: (_currentUser$name = currentUser?.name) !== null && _currentUser$name !== void 0 ? _currentUser$name : ''
26258 })]
26259 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
26260 __next40pxDefaultSize: true,
26261 __nextHasNoMarginBottom: true,
26262 value: inputComment,
26263 onChange: setInputComment,
26264 placeholder: (0,external_wp_i18n_namespaceObject._x)('Comment', 'noun')
26265 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26266 alignment: "right",
26267 spacing: "3",
26268 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26269 __next40pxDefaultSize: true,
26270 variant: "tertiary",
26271 text: (0,external_wp_i18n_namespaceObject._x)('Cancel', 'Cancel comment button'),
26272 onClick: handleCancel
26273 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26274 __next40pxDefaultSize: true,
26275 accessibleWhenDisabled: true,
26276 variant: "primary",
26277 text: (0,external_wp_i18n_namespaceObject._x)('Comment', 'Add comment button'),
26278 disabled: 0 === sanitizeCommentString(inputComment).length,
26279 onClick: () => {
26280 onSubmit(inputComment);
26281 setInputComment('');
26282 }
26283 })]
26284 })]
26285 });
26286 }
26287
26288 ;// ./packages/editor/build-module/components/collab-sidebar/comment-button.js
26289 /**
26290 * WordPress dependencies
26291 */
26292
26293
26294
26295
26296
26297 /**
26298 * Internal dependencies
26299 */
26300
26301
26302 const {
26303 __unstableCommentIconFill
26304 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
26305 const AddCommentButton = ({
26306 onClick
26307 }) => {
26308 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(__unstableCommentIconFill, {
26309 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
26310 icon: library_comment,
26311 onClick: onClick,
26312 "aria-haspopup": "dialog",
26313 children: (0,external_wp_i18n_namespaceObject._x)('Comment', 'Add comment button')
26314 })
26315 });
26316 };
26317 /* harmony default export */ const comment_button = (AddCommentButton);
26318
26319 ;// ./packages/editor/build-module/components/collab-sidebar/comment-button-toolbar.js
26320 /**
26321 * WordPress dependencies
26322 */
26323
26324
26325
26326
26327
26328 /**
26329 * Internal dependencies
26330 */
26331
26332
26333 const {
26334 __unstableCommentIconToolbarFill
26335 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
26336 const AddCommentToolbarButton = ({
26337 onClick
26338 }) => {
26339 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(__unstableCommentIconToolbarFill, {
26340 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, {
26341 accessibleWhenDisabled: true,
26342 icon: library_comment,
26343 label: (0,external_wp_i18n_namespaceObject._x)('Comment', 'View comment'),
26344 onClick: onClick
26345 })
26346 });
26347 };
26348 /* harmony default export */ const comment_button_toolbar = (AddCommentToolbarButton);
26349
26350 ;// ./packages/editor/build-module/components/collab-sidebar/index.js
26351 /**
26352 * WordPress dependencies
26353 */
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364 /**
26365 * Internal dependencies
26366 */
26367
26368
26369
26370
26371
26372
26373
26374
26375 const threadsEmptyArray = [];
26376 const isBlockCommentExperimentEnabled = window?.__experimentalEnableBlockComment;
26377 const modifyBlockCommentAttributes = settings => {
26378 if (!settings.attributes.blockCommentId) {
26379 settings.attributes = {
26380 ...settings.attributes,
26381 blockCommentId: {
26382 type: 'number'
26383 }
26384 };
26385 }
26386 return settings;
26387 };
26388
26389 // Apply the filter to all core blocks
26390 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'block-comment/modify-core-block-attributes', modifyBlockCommentAttributes);
26391
26392 /**
26393 * Renders the Collab sidebar.
26394 */
26395 function CollabSidebar() {
26396 const {
26397 createNotice
26398 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26399 const {
26400 saveEntityRecord,
26401 deleteEntityRecord
26402 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26403 const {
26404 getEntityRecord
26405 } = (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store);
26406 const {
26407 enableComplementaryArea
26408 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
26409 const [blockCommentID, setBlockCommentID] = (0,external_wp_element_namespaceObject.useState)(null);
26410 const [showCommentBoard, setShowCommentBoard] = (0,external_wp_element_namespaceObject.useState)(false);
26411 const {
26412 postId
26413 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26414 return {
26415 postId: select(store_store).getCurrentPostId()
26416 };
26417 }, []);
26418 const postStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
26419 const post = select(store_store).getCurrentPost();
26420 return {
26421 postStatus: post?.status
26422 };
26423 }, []);
26424 const threads = (0,external_wp_data_namespaceObject.useSelect)(select => {
26425 if (!postId) {
26426 return threadsEmptyArray;
26427 }
26428 const {
26429 getEntityRecords
26430 } = select(external_wp_coreData_namespaceObject.store);
26431 const data = getEntityRecords('root', 'comment', {
26432 post: postId,
26433 type: 'block_comment',
26434 status: 'any',
26435 per_page: 100
26436 });
26437 return data || threadsEmptyArray;
26438 }, [postId]);
26439 const clientId = (0,external_wp_data_namespaceObject.useSelect)(select => {
26440 const {
26441 getSelectedBlockClientId
26442 } = select(external_wp_blockEditor_namespaceObject.store);
26443 return getSelectedBlockClientId();
26444 }, []);
26445 const blockDetails = (0,external_wp_data_namespaceObject.useSelect)(select => {
26446 return clientId ? select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId) : null;
26447 }, [clientId]);
26448
26449 // Get the dispatch functions to save the comment and update the block attributes.
26450 const {
26451 updateBlockAttributes
26452 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
26453
26454 // Process comments to build the tree structure
26455 const resultComments = (0,external_wp_element_namespaceObject.useMemo)(() => {
26456 // Create a compare to store the references to all objects by id
26457 const compare = {};
26458 const result = [];
26459 const filteredComments = threads.filter(comment => comment.status !== 'trash');
26460
26461 // Initialize each object with an empty `reply` array
26462 filteredComments.forEach(item => {
26463 compare[item.id] = {
26464 ...item,
26465 reply: []
26466 };
26467 });
26468
26469 // Iterate over the data to build the tree structure
26470 filteredComments.forEach(item => {
26471 if (item.parent === 0) {
26472 // If parent is 0, it's a root item, push it to the result array
26473 result.push(compare[item.id]);
26474 } else if (compare[item.parent]) {
26475 // Otherwise, find its parent and push it to the parent's `reply` array
26476 compare[item.parent].reply.push(compare[item.id]);
26477 }
26478 });
26479 return result;
26480 }, [threads]);
26481 const openCollabBoard = () => {
26482 setShowCommentBoard(true);
26483 enableComplementaryArea('core', 'edit-post/collab-sidebar');
26484 };
26485
26486 // Function to save the comment.
26487 const addNewComment = async (comment, parentCommentId) => {
26488 const args = {
26489 post: postId,
26490 content: comment,
26491 comment_type: 'block_comment',
26492 comment_approved: 0
26493 };
26494
26495 // Create a new object, conditionally including the parent property
26496 const updatedArgs = {
26497 ...args,
26498 ...(parentCommentId ? {
26499 parent: parentCommentId
26500 } : {})
26501 };
26502 const savedRecord = await saveEntityRecord('root', 'comment', updatedArgs);
26503 if (savedRecord) {
26504 // If it's a main comment, update the block attributes with the comment id.
26505 if (!parentCommentId) {
26506 updateBlockAttributes(clientId, {
26507 blockCommentId: savedRecord?.id
26508 });
26509 }
26510 createNotice('snackbar', parentCommentId ?
26511 // translators: Reply added successfully
26512 (0,external_wp_i18n_namespaceObject.__)('Reply added successfully.') :
26513 // translators: Comment added successfully
26514 (0,external_wp_i18n_namespaceObject.__)('Comment added successfully.'), {
26515 type: 'snackbar',
26516 isDismissible: true
26517 });
26518 } else {
26519 onError();
26520 }
26521 };
26522 const onCommentResolve = async commentId => {
26523 const savedRecord = await saveEntityRecord('root', 'comment', {
26524 id: commentId,
26525 status: 'approved'
26526 });
26527 if (savedRecord) {
26528 // translators: Comment resolved successfully
26529 createNotice('snackbar', (0,external_wp_i18n_namespaceObject.__)('Comment marked as resolved.'), {
26530 type: 'snackbar',
26531 isDismissible: true
26532 });
26533 } else {
26534 onError();
26535 }
26536 };
26537 const onEditComment = async (commentId, comment) => {
26538 const savedRecord = await saveEntityRecord('root', 'comment', {
26539 id: commentId,
26540 content: comment
26541 });
26542 if (savedRecord) {
26543 createNotice('snackbar',
26544 // translators: Comment edited successfully
26545 (0,external_wp_i18n_namespaceObject.__)('Comment edited successfully.'), {
26546 type: 'snackbar',
26547 isDismissible: true
26548 });
26549 } else {
26550 onError();
26551 }
26552 };
26553 const onError = () => {
26554 createNotice('error',
26555 // translators: Error message when comment submission fails
26556 (0,external_wp_i18n_namespaceObject.__)('Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'), {
26557 isDismissible: true
26558 });
26559 };
26560 const onCommentDelete = async commentId => {
26561 const childComment = await getEntityRecord('root', 'comment', commentId);
26562 await deleteEntityRecord('root', 'comment', commentId);
26563 if (childComment && !childComment.parent) {
26564 updateBlockAttributes(clientId, {
26565 blockCommentId: undefined
26566 });
26567 }
26568 createNotice('snackbar',
26569 // translators: Comment deleted successfully
26570 (0,external_wp_i18n_namespaceObject.__)('Comment deleted successfully.'), {
26571 type: 'snackbar',
26572 isDismissible: true
26573 });
26574 };
26575 (0,external_wp_element_namespaceObject.useEffect)(() => {
26576 if (blockDetails) {
26577 setBlockCommentID(blockDetails?.attributes.blockCommentId);
26578 }
26579 }, [postId, clientId]);
26580
26581 // Check if the experimental flag is enabled.
26582 if (!isBlockCommentExperimentEnabled || postStatus.postStatus === 'publish') {
26583 return null; // or maybe return some message indicating no threads are available.
26584 }
26585 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26586 children: [!blockCommentID && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(comment_button, {
26587 onClick: openCollabBoard
26588 }), blockCommentID > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(comment_button_toolbar, {
26589 onClick: openCollabBoard
26590 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginSidebar, {
26591 identifier: collabSidebarName
26592 // translators: Comments sidebar title
26593 ,
26594 title: (0,external_wp_i18n_namespaceObject.__)('Comments'),
26595 icon: library_comment,
26596 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
26597 className: "editor-collab-sidebar-panel",
26598 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AddComment, {
26599 threads: resultComments,
26600 onSubmit: addNewComment,
26601 showCommentBoard: showCommentBoard,
26602 setShowCommentBoard: setShowCommentBoard
26603 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Comments, {
26604 threads: resultComments,
26605 onEditComment: onEditComment,
26606 onAddReply: addNewComment,
26607 onCommentDelete: onCommentDelete,
26608 onCommentResolve: onCommentResolve
26609 })]
26610 })
26611 })]
26612 });
26613 }
26614
26615 ;// ./packages/icons/build-module/library/next.js
26616 /**
26617 * WordPress dependencies
26618 */
26619
26620
26621 const next = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
26622 xmlns: "http://www.w3.org/2000/svg",
26623 viewBox: "0 0 24 24",
26624 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
26625 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"
26626 })
26627 });
26628 /* harmony default export */ const library_next = (next);
26629
26630 ;// ./packages/icons/build-module/library/previous.js
26631 /**
26632 * WordPress dependencies
26633 */
26634
26635
26636 const previous = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
26637 xmlns: "http://www.w3.org/2000/svg",
26638 viewBox: "0 0 24 24",
26639 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
26640 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"
26641 })
26642 });
26643 /* harmony default export */ const library_previous = (previous);
26644
26645 ;// ./packages/editor/build-module/components/collapsible-block-toolbar/index.js
26646 /**
26647 * External dependencies
26648 */
26649
26650
26651 /**
26652 * WordPress dependencies
26653 */
26654
26655
26656
26657
26658
26659
26660
26661 /**
26662 * Internal dependencies
26663 */
26664
26665
26666 const {
26667 useHasBlockToolbar
26668 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
26669 function CollapsibleBlockToolbar({
26670 isCollapsed,
26671 onToggle
26672 }) {
26673 const {
26674 blockSelectionStart
26675 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26676 return {
26677 blockSelectionStart: select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
26678 };
26679 }, []);
26680 const hasBlockToolbar = useHasBlockToolbar();
26681 const hasBlockSelection = !!blockSelectionStart;
26682 (0,external_wp_element_namespaceObject.useEffect)(() => {
26683 // If we have a new block selection, show the block tools
26684 if (blockSelectionStart) {
26685 onToggle(false);
26686 }
26687 }, [blockSelectionStart, onToggle]);
26688 if (!hasBlockToolbar) {
26689 return null;
26690 }
26691 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26692 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26693 className: dist_clsx('editor-collapsible-block-toolbar', {
26694 'is-collapsed': isCollapsed || !hasBlockSelection
26695 }),
26696 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
26697 hideDragHandle: true
26698 })
26699 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover.Slot, {
26700 name: "block-toolbar"
26701 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26702 className: "editor-collapsible-block-toolbar__toggle",
26703 icon: isCollapsed ? library_next : library_previous,
26704 onClick: () => {
26705 onToggle(!isCollapsed);
26706 },
26707 label: isCollapsed ? (0,external_wp_i18n_namespaceObject.__)('Show block tools') : (0,external_wp_i18n_namespaceObject.__)('Hide block tools'),
26708 size: "compact"
26709 })]
26710 });
26711 }
26712
26713 ;// ./packages/icons/build-module/library/plus.js
26714 /**
26715 * WordPress dependencies
26716 */
26717
26718
26719 const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
26720 xmlns: "http://www.w3.org/2000/svg",
26721 viewBox: "0 0 24 24",
26722 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
26723 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"
26724 })
26725 });
26726 /* harmony default export */ const library_plus = (plus);
26727
26728 ;// ./packages/editor/build-module/components/document-tools/index.js
26729 /**
26730 * External dependencies
26731 */
26732
26733
26734 /**
26735 * WordPress dependencies
26736 */
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747 /**
26748 * Internal dependencies
26749 */
26750
26751
26752
26753
26754
26755 function DocumentTools({
26756 className,
26757 disableBlockTools = false
26758 }) {
26759 const {
26760 setIsInserterOpened,
26761 setIsListViewOpened
26762 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
26763 const {
26764 isDistractionFree,
26765 isInserterOpened,
26766 isListViewOpen,
26767 listViewShortcut,
26768 inserterSidebarToggleRef,
26769 listViewToggleRef,
26770 showIconLabels
26771 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26772 const {
26773 get
26774 } = select(external_wp_preferences_namespaceObject.store);
26775 const {
26776 isListViewOpened,
26777 getEditorMode,
26778 getInserterSidebarToggleRef,
26779 getListViewToggleRef
26780 } = unlock(select(store_store));
26781 const {
26782 getShortcutRepresentation
26783 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
26784 return {
26785 isInserterOpened: select(store_store).isInserterOpened(),
26786 isListViewOpen: isListViewOpened(),
26787 listViewShortcut: getShortcutRepresentation('core/editor/toggle-list-view'),
26788 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
26789 listViewToggleRef: getListViewToggleRef(),
26790 showIconLabels: get('core', 'showIconLabels'),
26791 isDistractionFree: get('core', 'distractionFree'),
26792 isVisualMode: getEditorMode() === 'visual'
26793 };
26794 }, []);
26795 const preventDefault = event => {
26796 // Because the inserter behaves like a dialog,
26797 // if the inserter is opened already then when we click on the toggle button
26798 // then the initial click event will close the inserter and then be propagated
26799 // to the inserter toggle and it will open it again.
26800 // To prevent this we need to stop the propagation of the event.
26801 // This won't be necessary when the inserter no longer behaves like a dialog.
26802
26803 if (isInserterOpened) {
26804 event.preventDefault();
26805 }
26806 };
26807 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
26808 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('wide');
26809
26810 /* translators: accessibility text for the editor toolbar */
26811 const toolbarAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Document tools');
26812 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
26813 const toggleInserter = (0,external_wp_element_namespaceObject.useCallback)(() => setIsInserterOpened(!isInserterOpened), [isInserterOpened, setIsInserterOpened]);
26814
26815 /* translators: button label text should, if possible, be under 16 characters. */
26816 const longLabel = (0,external_wp_i18n_namespaceObject._x)('Block Inserter', 'Generic label for block inserter button');
26817 const shortLabel = !isInserterOpened ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close');
26818 return (
26819 /*#__PURE__*/
26820 // Some plugins expect and use the `edit-post-header-toolbar` CSS class to
26821 // find the toolbar and inject UI elements into it. This is not officially
26822 // supported, but we're keeping it in the list of class names for backwards
26823 // compatibility.
26824 (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
26825 className: dist_clsx('editor-document-tools', 'edit-post-header-toolbar', className),
26826 "aria-label": toolbarAriaLabel,
26827 variant: "unstyled",
26828 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
26829 className: "editor-document-tools__left",
26830 children: [!isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
26831 ref: inserterSidebarToggleRef,
26832 as: external_wp_components_namespaceObject.Button,
26833 className: "editor-document-tools__inserter-toggle",
26834 variant: "primary",
26835 isPressed: isInserterOpened,
26836 onMouseDown: preventDefault,
26837 onClick: toggleInserter,
26838 disabled: disableBlockTools,
26839 icon: library_plus,
26840 label: showIconLabels ? shortLabel : longLabel,
26841 showTooltip: !showIconLabels,
26842 "aria-expanded": isInserterOpened
26843 }), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26844 children: [isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
26845 as: external_wp_blockEditor_namespaceObject.ToolSelector,
26846 showTooltip: !showIconLabels,
26847 variant: showIconLabels ? 'tertiary' : undefined,
26848 disabled: disableBlockTools,
26849 size: "compact"
26850 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
26851 as: editor_history_undo,
26852 showTooltip: !showIconLabels,
26853 variant: showIconLabels ? 'tertiary' : undefined,
26854 size: "compact"
26855 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
26856 as: editor_history_redo,
26857 showTooltip: !showIconLabels,
26858 variant: showIconLabels ? 'tertiary' : undefined,
26859 size: "compact"
26860 }), !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
26861 as: external_wp_components_namespaceObject.Button,
26862 className: "editor-document-tools__document-overview-toggle",
26863 icon: list_view,
26864 disabled: disableBlockTools,
26865 isPressed: isListViewOpen
26866 /* translators: button label text should, if possible, be under 16 characters. */,
26867 label: (0,external_wp_i18n_namespaceObject.__)('Document Overview'),
26868 onClick: toggleListView,
26869 shortcut: listViewShortcut,
26870 showTooltip: !showIconLabels,
26871 variant: showIconLabels ? 'tertiary' : undefined,
26872 "aria-expanded": isListViewOpen,
26873 ref: listViewToggleRef,
26874 size: "compact"
26875 })]
26876 })]
26877 })
26878 })
26879 );
26880 }
26881 /* harmony default export */ const document_tools = (DocumentTools);
26882
26883 ;// ./packages/editor/build-module/components/more-menu/copy-content-menu-item.js
26884 /**
26885 * WordPress dependencies
26886 */
26887
26888
26889
26890
26891
26892
26893
26894
26895 /**
26896 * Internal dependencies
26897 */
26898
26899
26900 function CopyContentMenuItem() {
26901 const {
26902 createNotice
26903 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26904 const {
26905 getCurrentPostId,
26906 getCurrentPostType
26907 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
26908 const {
26909 getEditedEntityRecord
26910 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
26911 function getText() {
26912 const record = getEditedEntityRecord('postType', getCurrentPostType(), getCurrentPostId());
26913 if (!record) {
26914 return '';
26915 }
26916 if (typeof record.content === 'function') {
26917 return record.content(record);
26918 } else if (record.blocks) {
26919 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
26920 } else if (record.content) {
26921 return record.content;
26922 }
26923 }
26924 function onSuccess() {
26925 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), {
26926 isDismissible: true,
26927 type: 'snackbar'
26928 });
26929 }
26930 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess);
26931 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
26932 ref: ref,
26933 children: (0,external_wp_i18n_namespaceObject.__)('Copy all blocks')
26934 });
26935 }
26936
26937 ;// ./packages/editor/build-module/components/mode-switcher/index.js
26938 /**
26939 * WordPress dependencies
26940 */
26941
26942
26943
26944
26945
26946 /**
26947 * Internal dependencies
26948 */
26949
26950
26951 /**
26952 * Set of available mode options.
26953 *
26954 * @type {Array}
26955 */
26956
26957 const MODES = [{
26958 value: 'visual',
26959 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor')
26960 }, {
26961 value: 'text',
26962 label: (0,external_wp_i18n_namespaceObject.__)('Code editor')
26963 }];
26964 function ModeSwitcher() {
26965 const {
26966 shortcut,
26967 isRichEditingEnabled,
26968 isCodeEditingEnabled,
26969 mode
26970 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
26971 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-mode'),
26972 isRichEditingEnabled: select(store_store).getEditorSettings().richEditingEnabled,
26973 isCodeEditingEnabled: select(store_store).getEditorSettings().codeEditingEnabled,
26974 mode: select(store_store).getEditorMode()
26975 }), []);
26976 const {
26977 switchEditorMode
26978 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
26979 let selectedMode = mode;
26980 if (!isRichEditingEnabled && mode === 'visual') {
26981 selectedMode = 'text';
26982 }
26983 if (!isCodeEditingEnabled && mode === 'text') {
26984 selectedMode = 'visual';
26985 }
26986 const choices = MODES.map(choice => {
26987 if (!isCodeEditingEnabled && choice.value === 'text') {
26988 choice = {
26989 ...choice,
26990 disabled: true
26991 };
26992 }
26993 if (!isRichEditingEnabled && choice.value === 'visual') {
26994 choice = {
26995 ...choice,
26996 disabled: true,
26997 info: (0,external_wp_i18n_namespaceObject.__)('You can enable the visual editor in your profile settings.')
26998 };
26999 }
27000 if (choice.value !== selectedMode && !choice.disabled) {
27001 return {
27002 ...choice,
27003 shortcut
27004 };
27005 }
27006 return choice;
27007 });
27008 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
27009 label: (0,external_wp_i18n_namespaceObject.__)('Editor'),
27010 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItemsChoice, {
27011 choices: choices,
27012 value: selectedMode,
27013 onSelect: switchEditorMode
27014 })
27015 });
27016 }
27017 /* harmony default export */ const mode_switcher = (ModeSwitcher);
27018
27019 ;// ./packages/editor/build-module/components/more-menu/tools-more-menu-group.js
27020 /**
27021 * WordPress dependencies
27022 */
27023
27024
27025 const {
27026 Fill: ToolsMoreMenuGroup,
27027 Slot: tools_more_menu_group_Slot
27028 } = (0,external_wp_components_namespaceObject.createSlotFill)('ToolsMoreMenuGroup');
27029 ToolsMoreMenuGroup.Slot = ({
27030 fillProps
27031 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group_Slot, {
27032 fillProps: fillProps
27033 });
27034 /* harmony default export */ const tools_more_menu_group = (ToolsMoreMenuGroup);
27035
27036 ;// ./packages/editor/build-module/components/more-menu/view-more-menu-group.js
27037 /**
27038 * WordPress dependencies
27039 */
27040
27041
27042
27043 const {
27044 Fill: ViewMoreMenuGroup,
27045 Slot: view_more_menu_group_Slot
27046 } = (0,external_wp_components_namespaceObject.createSlotFill)(external_wp_element_namespaceObject.Platform.OS === 'web' ? Symbol('ViewMoreMenuGroup') : 'ViewMoreMenuGroup');
27047 ViewMoreMenuGroup.Slot = ({
27048 fillProps
27049 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group_Slot, {
27050 fillProps: fillProps
27051 });
27052 /* harmony default export */ const view_more_menu_group = (ViewMoreMenuGroup);
27053
27054 ;// ./packages/editor/build-module/components/more-menu/index.js
27055 /**
27056 * WordPress dependencies
27057 */
27058
27059
27060
27061
27062
27063
27064
27065
27066 /**
27067 * Internal dependencies
27068 */
27069
27070
27071
27072
27073
27074
27075 function MoreMenu() {
27076 const {
27077 openModal
27078 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27079 const {
27080 set: setPreference
27081 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
27082 const {
27083 toggleDistractionFree
27084 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
27085 const showIconLabels = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_preferences_namespaceObject.store).get('core', 'showIconLabels'), []);
27086 const turnOffDistractionFree = () => {
27087 setPreference('core', 'distractionFree', false);
27088 };
27089 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27090 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
27091 icon: more_vertical,
27092 label: (0,external_wp_i18n_namespaceObject.__)('Options'),
27093 popoverProps: {
27094 placement: 'bottom-end',
27095 className: 'more-menu-dropdown__content'
27096 },
27097 toggleProps: {
27098 showTooltip: !showIconLabels,
27099 ...(showIconLabels && {
27100 variant: 'tertiary'
27101 }),
27102 tooltipPosition: 'bottom',
27103 size: 'compact'
27104 },
27105 children: ({
27106 onClose
27107 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27108 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
27109 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun'),
27110 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
27111 scope: "core",
27112 name: "fixedToolbar",
27113 onToggle: turnOffDistractionFree,
27114 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
27115 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
27116 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
27117 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
27118 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
27119 scope: "core",
27120 name: "distractionFree",
27121 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free'),
27122 info: (0,external_wp_i18n_namespaceObject.__)('Write with calmness'),
27123 handleToggling: false,
27124 onToggle: toggleDistractionFree,
27125 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode activated'),
27126 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode deactivated'),
27127 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('\\')
27128 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
27129 scope: "core",
27130 name: "focusMode",
27131 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'),
27132 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'),
27133 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'),
27134 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated')
27135 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group.Slot, {
27136 fillProps: {
27137 onClose
27138 }
27139 })]
27140 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(mode_switcher, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item.Slot, {
27141 name: "core/plugin-more-menu",
27142 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
27143 as: external_wp_components_namespaceObject.MenuGroup,
27144 fillProps: {
27145 onClick: onClose
27146 }
27147 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
27148 label: (0,external_wp_i18n_namespaceObject.__)('Tools'),
27149 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
27150 onClick: () => openModal('editor/keyboard-shortcut-help'),
27151 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h'),
27152 children: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')
27153 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyContentMenuItem, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
27154 icon: library_external,
27155 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/wordpress-block-editor/'),
27156 target: "_blank",
27157 rel: "noopener noreferrer",
27158 children: [(0,external_wp_i18n_namespaceObject.__)('Help'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
27159 as: "span",
27160 children: /* translators: accessibility text */
27161 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
27162 })]
27163 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group.Slot, {
27164 fillProps: {
27165 onClose
27166 }
27167 })]
27168 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
27169 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
27170 onClick: () => openModal('editor/preferences'),
27171 children: (0,external_wp_i18n_namespaceObject.__)('Preferences')
27172 })
27173 })]
27174 })
27175 })
27176 });
27177 }
27178
27179 ;// ./packages/editor/build-module/components/post-publish-button/post-publish-button-or-toggle.js
27180 /**
27181 * WordPress dependencies
27182 */
27183
27184
27185
27186 /**
27187 * Internal dependencies
27188 */
27189
27190
27191
27192 function PostPublishButtonOrToggle({
27193 forceIsDirty,
27194 hasPublishAction,
27195 isBeingScheduled,
27196 isPending,
27197 isPublished,
27198 isPublishSidebarEnabled,
27199 isPublishSidebarOpened,
27200 isScheduled,
27201 togglePublishSidebar,
27202 setEntitiesSavedStatesCallback,
27203 postStatusHasChanged,
27204 postStatus
27205 }) {
27206 const IS_TOGGLE = 'toggle';
27207 const IS_BUTTON = 'button';
27208 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
27209 let component;
27210
27211 /**
27212 * Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):
27213 *
27214 * 1) We want to show a BUTTON when the post status is at the _final stage_
27215 * for a particular role (see https://wordpress.org/documentation/article/post-status/):
27216 *
27217 * - is published
27218 * - post status has changed explicitely to something different than 'future' or 'publish'
27219 * - is scheduled to be published
27220 * - is pending and can't be published (but only for viewports >= medium).
27221 * Originally, we considered showing a button for pending posts that couldn't be published
27222 * (for example, for an author with the contributor role). Some languages can have
27223 * long translations for "Submit for review", so given the lack of UI real estate available
27224 * we decided to take into account the viewport in that case.
27225 * See: https://github.com/WordPress/gutenberg/issues/10475
27226 *
27227 * 2) Then, in small viewports, we'll show a TOGGLE.
27228 *
27229 * 3) Finally, we'll use the publish sidebar status to decide:
27230 *
27231 * - if it is enabled, we show a TOGGLE
27232 * - if it is disabled, we show a BUTTON
27233 */
27234 if (isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || isScheduled && isBeingScheduled || isPending && !hasPublishAction && !isSmallerThanMediumViewport) {
27235 component = IS_BUTTON;
27236 } else if (isSmallerThanMediumViewport || isPublishSidebarEnabled) {
27237 component = IS_TOGGLE;
27238 } else {
27239 component = IS_BUTTON;
27240 }
27241 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
27242 forceIsDirty: forceIsDirty,
27243 isOpen: isPublishSidebarOpened,
27244 isToggle: component === IS_TOGGLE,
27245 onToggle: togglePublishSidebar,
27246 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
27247 });
27248 }
27249 /* harmony default export */ const post_publish_button_or_toggle = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
27250 var _select$getCurrentPos;
27251 return {
27252 hasPublishAction: (_select$getCurrentPos = select(store_store).getCurrentPost()?._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false,
27253 isBeingScheduled: select(store_store).isEditedPostBeingScheduled(),
27254 isPending: select(store_store).isCurrentPostPending(),
27255 isPublished: select(store_store).isCurrentPostPublished(),
27256 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled(),
27257 isPublishSidebarOpened: select(store_store).isPublishSidebarOpened(),
27258 isScheduled: select(store_store).isCurrentPostScheduled(),
27259 postStatus: select(store_store).getEditedPostAttribute('status'),
27260 postStatusHasChanged: select(store_store).getPostEdits()?.status
27261 };
27262 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
27263 const {
27264 togglePublishSidebar
27265 } = dispatch(store_store);
27266 return {
27267 togglePublishSidebar
27268 };
27269 }))(PostPublishButtonOrToggle));
27270
27271 ;// ./packages/editor/build-module/components/post-view-link/index.js
27272 /**
27273 * WordPress dependencies
27274 */
27275
27276
27277
27278
27279
27280
27281
27282 /**
27283 * Internal dependencies
27284 */
27285
27286
27287 function PostViewLink() {
27288 const {
27289 hasLoaded,
27290 permalink,
27291 isPublished,
27292 label,
27293 showIconLabels
27294 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27295 // Grab post type to retrieve the view_item label.
27296 const postTypeSlug = select(store_store).getCurrentPostType();
27297 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
27298 const {
27299 get
27300 } = select(external_wp_preferences_namespaceObject.store);
27301 return {
27302 permalink: select(store_store).getPermalink(),
27303 isPublished: select(store_store).isCurrentPostPublished(),
27304 label: postType?.labels.view_item,
27305 hasLoaded: !!postType,
27306 showIconLabels: get('core', 'showIconLabels')
27307 };
27308 }, []);
27309
27310 // Only render the view button if the post is published and has a permalink.
27311 if (!isPublished || !permalink || !hasLoaded) {
27312 return null;
27313 }
27314 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27315 icon: library_external,
27316 label: label || (0,external_wp_i18n_namespaceObject.__)('View post'),
27317 href: permalink,
27318 target: "_blank",
27319 showTooltip: !showIconLabels,
27320 size: "compact"
27321 });
27322 }
27323
27324 ;// ./packages/icons/build-module/library/desktop.js
27325 /**
27326 * WordPress dependencies
27327 */
27328
27329
27330 const desktop = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
27331 xmlns: "http://www.w3.org/2000/svg",
27332 viewBox: "0 0 24 24",
27333 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
27334 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"
27335 })
27336 });
27337 /* harmony default export */ const library_desktop = (desktop);
27338
27339 ;// ./packages/icons/build-module/library/mobile.js
27340 /**
27341 * WordPress dependencies
27342 */
27343
27344
27345 const mobile = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
27346 xmlns: "http://www.w3.org/2000/svg",
27347 viewBox: "0 0 24 24",
27348 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
27349 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"
27350 })
27351 });
27352 /* harmony default export */ const library_mobile = (mobile);
27353
27354 ;// ./packages/icons/build-module/library/tablet.js
27355 /**
27356 * WordPress dependencies
27357 */
27358
27359
27360 const tablet = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
27361 xmlns: "http://www.w3.org/2000/svg",
27362 viewBox: "0 0 24 24",
27363 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
27364 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"
27365 })
27366 });
27367 /* harmony default export */ const library_tablet = (tablet);
27368
27369 ;// ./packages/editor/build-module/components/preview-dropdown/index.js
27370 /**
27371 * External dependencies
27372 */
27373
27374
27375 /**
27376 * WordPress dependencies
27377 */
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387 /**
27388 * Internal dependencies
27389 */
27390
27391
27392
27393
27394
27395 function PreviewDropdown({
27396 forceIsAutosaveable,
27397 disabled
27398 }) {
27399 const {
27400 deviceType,
27401 homeUrl,
27402 isTemplate,
27403 isViewable,
27404 showIconLabels
27405 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27406 var _getPostType$viewable;
27407 const {
27408 getDeviceType,
27409 getCurrentPostType
27410 } = select(store_store);
27411 const {
27412 getEntityRecord,
27413 getPostType
27414 } = select(external_wp_coreData_namespaceObject.store);
27415 const {
27416 get
27417 } = select(external_wp_preferences_namespaceObject.store);
27418 const _currentPostType = getCurrentPostType();
27419 return {
27420 deviceType: getDeviceType(),
27421 homeUrl: getEntityRecord('root', '__unstableBase')?.home,
27422 isTemplate: _currentPostType === 'wp_template',
27423 isViewable: (_getPostType$viewable = getPostType(_currentPostType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
27424 showIconLabels: get('core', 'showIconLabels')
27425 };
27426 }, []);
27427 const {
27428 setDeviceType
27429 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
27430 const {
27431 resetZoomLevel
27432 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store));
27433 const handleDevicePreviewChange = newDeviceType => {
27434 setDeviceType(newDeviceType);
27435 resetZoomLevel();
27436 };
27437 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
27438 if (isMobile) {
27439 return null;
27440 }
27441 const popoverProps = {
27442 placement: 'bottom-end'
27443 };
27444 const toggleProps = {
27445 className: 'editor-preview-dropdown__toggle',
27446 iconPosition: 'right',
27447 size: 'compact',
27448 showTooltip: !showIconLabels,
27449 disabled,
27450 accessibleWhenDisabled: disabled
27451 };
27452 const menuProps = {
27453 'aria-label': (0,external_wp_i18n_namespaceObject.__)('View options')
27454 };
27455 const deviceIcons = {
27456 desktop: library_desktop,
27457 mobile: library_mobile,
27458 tablet: library_tablet
27459 };
27460
27461 /**
27462 * The choices for the device type.
27463 *
27464 * @type {Array}
27465 */
27466 const choices = [{
27467 value: 'Desktop',
27468 label: (0,external_wp_i18n_namespaceObject.__)('Desktop'),
27469 icon: library_desktop
27470 }, {
27471 value: 'Tablet',
27472 label: (0,external_wp_i18n_namespaceObject.__)('Tablet'),
27473 icon: library_tablet
27474 }, {
27475 value: 'Mobile',
27476 label: (0,external_wp_i18n_namespaceObject.__)('Mobile'),
27477 icon: library_mobile
27478 }];
27479 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
27480 className: dist_clsx('editor-preview-dropdown', `editor-preview-dropdown--${deviceType.toLowerCase()}`),
27481 popoverProps: popoverProps,
27482 toggleProps: toggleProps,
27483 menuProps: menuProps,
27484 icon: deviceIcons[deviceType.toLowerCase()],
27485 label: (0,external_wp_i18n_namespaceObject.__)('View'),
27486 disableOpenOnArrowDown: disabled,
27487 children: ({
27488 onClose
27489 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27490 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
27491 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItemsChoice, {
27492 choices: choices,
27493 value: deviceType,
27494 onSelect: handleDevicePreviewChange
27495 })
27496 }), isTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
27497 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
27498 href: homeUrl,
27499 target: "_blank",
27500 icon: library_external,
27501 onClick: onClose,
27502 children: [(0,external_wp_i18n_namespaceObject.__)('View site'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
27503 as: "span",
27504 children: /* translators: accessibility text */
27505 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
27506 })]
27507 })
27508 }), isViewable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
27509 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
27510 className: "editor-preview-dropdown__button-external",
27511 role: "menuitem",
27512 forceIsAutosaveable: forceIsAutosaveable,
27513 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Preview in new tab'),
27514 textContent: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27515 children: [(0,external_wp_i18n_namespaceObject.__)('Preview in new tab'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
27516 icon: library_external
27517 })]
27518 }),
27519 onPreview: onClose
27520 })
27521 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item.Slot, {
27522 name: "core/plugin-preview-menu",
27523 as: external_wp_components_namespaceObject.MenuGroup,
27524 fillProps: {
27525 onClick: onClose
27526 }
27527 })]
27528 })
27529 });
27530 }
27531
27532 ;// ./packages/icons/build-module/library/square.js
27533 /**
27534 * WordPress dependencies
27535 */
27536
27537
27538 const square = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
27539 xmlns: "http://www.w3.org/2000/svg",
27540 viewBox: "0 0 24 24",
27541 fill: "none",
27542 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
27543 fill: "none",
27544 d: "M5.75 12.75V18.25H11.25M12.75 5.75H18.25V11.25",
27545 stroke: "currentColor",
27546 strokeWidth: "1.5",
27547 strokeLinecap: "square"
27548 })
27549 });
27550 /* harmony default export */ const library_square = (square);
27551
27552 ;// ./packages/editor/build-module/components/zoom-out-toggle/index.js
27553 /**
27554 * WordPress dependencies
27555 */
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566 /**
27567 * Internal dependencies
27568 */
27569
27570
27571 const ZoomOutToggle = ({
27572 disabled
27573 }) => {
27574 const {
27575 isZoomOut,
27576 showIconLabels
27577 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
27578 isZoomOut: unlock(select(external_wp_blockEditor_namespaceObject.store)).isZoomOut(),
27579 showIconLabels: select(external_wp_preferences_namespaceObject.store).get('core', 'showIconLabels')
27580 }));
27581 const {
27582 resetZoomLevel,
27583 setZoomLevel
27584 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store));
27585 const {
27586 registerShortcut,
27587 unregisterShortcut
27588 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
27589 (0,external_wp_element_namespaceObject.useEffect)(() => {
27590 registerShortcut({
27591 name: 'core/editor/zoom',
27592 category: 'global',
27593 description: (0,external_wp_i18n_namespaceObject.__)('Enter or exit zoom out.'),
27594 keyCombination: {
27595 // `primaryShift+0` (`ctrl+shift+0`) is the shortcut for switching
27596 // to input mode in Windows, so apply a different key combination.
27597 modifier: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? 'primaryShift' : 'secondary',
27598 character: '0'
27599 }
27600 });
27601 return () => {
27602 unregisterShortcut('core/editor/zoom');
27603 };
27604 }, [registerShortcut, unregisterShortcut]);
27605 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/zoom', () => {
27606 if (isZoomOut) {
27607 resetZoomLevel();
27608 } else {
27609 setZoomLevel('auto-scaled');
27610 }
27611 });
27612 const handleZoomOut = () => {
27613 if (isZoomOut) {
27614 resetZoomLevel();
27615 } else {
27616 setZoomLevel('auto-scaled');
27617 }
27618 };
27619 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27620 accessibleWhenDisabled: true,
27621 disabled: disabled,
27622 onClick: handleZoomOut,
27623 icon: library_square,
27624 label: (0,external_wp_i18n_namespaceObject.__)('Zoom Out'),
27625 isPressed: isZoomOut,
27626 size: "compact",
27627 showTooltip: !showIconLabels
27628 });
27629 };
27630 /* harmony default export */ const zoom_out_toggle = (ZoomOutToggle);
27631
27632 ;// ./packages/editor/build-module/components/header/index.js
27633 /**
27634 * WordPress dependencies
27635 */
27636
27637
27638
27639
27640
27641
27642
27643
27644 /**
27645 * Internal dependencies
27646 */
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661 const toolbarVariations = {
27662 distractionFreeDisabled: {
27663 y: '-50px'
27664 },
27665 distractionFreeHover: {
27666 y: 0
27667 },
27668 distractionFreeHidden: {
27669 y: '-50px'
27670 },
27671 visible: {
27672 y: 0
27673 },
27674 hidden: {
27675 y: 0
27676 }
27677 };
27678 const backButtonVariations = {
27679 distractionFreeDisabled: {
27680 x: '-100%'
27681 },
27682 distractionFreeHover: {
27683 x: 0
27684 },
27685 distractionFreeHidden: {
27686 x: '-100%'
27687 },
27688 visible: {
27689 x: 0
27690 },
27691 hidden: {
27692 x: 0
27693 }
27694 };
27695 function header_Header({
27696 customSaveButton,
27697 forceIsDirty,
27698 forceDisableBlockTools,
27699 setEntitiesSavedStatesCallback,
27700 title,
27701 isEditorIframed
27702 }) {
27703 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
27704 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
27705 const isTooNarrowForDocumentBar = (0,external_wp_compose_namespaceObject.useMediaQuery)('(max-width: 403px)');
27706 const {
27707 postType,
27708 isTextEditor,
27709 isPublishSidebarOpened,
27710 showIconLabels,
27711 hasFixedToolbar,
27712 hasBlockSelection,
27713 isNestedEntity
27714 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27715 const {
27716 get: getPreference
27717 } = select(external_wp_preferences_namespaceObject.store);
27718 const {
27719 getEditorMode,
27720 getEditorSettings,
27721 getCurrentPostType,
27722 isPublishSidebarOpened: _isPublishSidebarOpened
27723 } = select(store_store);
27724 return {
27725 postType: getCurrentPostType(),
27726 isTextEditor: getEditorMode() === 'text',
27727 isPublishSidebarOpened: _isPublishSidebarOpened(),
27728 showIconLabels: getPreference('core', 'showIconLabels'),
27729 hasFixedToolbar: getPreference('core', 'fixedToolbar'),
27730 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart(),
27731 isNestedEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord
27732 };
27733 }, []);
27734 const canBeZoomedOut = ['post', 'page', 'wp_template'].includes(postType);
27735 const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0,external_wp_element_namespaceObject.useState)(true);
27736 const hasCenter = (!hasBlockSelection || isBlockToolsCollapsed) && !isTooNarrowForDocumentBar;
27737 const hasBackButton = useHasBackButton();
27738 /*
27739 * The edit-post-header classname is only kept for backward compatability
27740 * as some plugins might be relying on its presence.
27741 */
27742 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
27743 className: "editor-header edit-post-header",
27744 children: [hasBackButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
27745 className: "editor-header__back-button",
27746 variants: backButtonVariations,
27747 transition: {
27748 type: 'tween'
27749 },
27750 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button.Slot, {})
27751 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
27752 variants: toolbarVariations,
27753 className: "editor-header__toolbar",
27754 transition: {
27755 type: 'tween'
27756 },
27757 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_tools, {
27758 disableBlockTools: forceDisableBlockTools || isTextEditor
27759 }), hasFixedToolbar && isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CollapsibleBlockToolbar, {
27760 isCollapsed: isBlockToolsCollapsed,
27761 onToggle: setIsBlockToolsCollapsed
27762 })]
27763 }), hasCenter && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
27764 className: "editor-header__center",
27765 variants: toolbarVariations,
27766 transition: {
27767 type: 'tween'
27768 },
27769 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentBar, {
27770 title: title
27771 })
27772 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
27773 variants: toolbarVariations,
27774 transition: {
27775 type: 'tween'
27776 },
27777 className: "editor-header__settings",
27778 children: [!customSaveButton && !isPublishSidebarOpened &&
27779 /*#__PURE__*/
27780 /*
27781 * This button isn't completely hidden by the publish sidebar.
27782 * We can't hide the whole toolbar when the publish sidebar is open because
27783 * we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
27784 * We track that DOM node to return focus to the PostPublishButtonOrToggle
27785 * when the publish sidebar has been closed.
27786 */
27787 (0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSavedState, {
27788 forceIsDirty: forceIsDirty
27789 }), canBeZoomedOut && isEditorIframed && isWideViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(zoom_out_toggle, {
27790 disabled: forceDisableBlockTools
27791 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreviewDropdown, {
27792 forceIsAutosaveable: forceIsDirty,
27793 disabled: isNestedEntity
27794 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
27795 className: "editor-header__post-preview-button",
27796 forceIsAutosaveable: forceIsDirty
27797 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostViewLink, {}), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items.Slot, {
27798 scope: "core"
27799 }), !customSaveButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button_or_toggle, {
27800 forceIsDirty: forceIsDirty,
27801 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
27802 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CollabSidebar, {}), customSaveButton, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MoreMenu, {})]
27803 })]
27804 });
27805 }
27806 /* harmony default export */ const components_header = (header_Header);
27807
27808 ;// ./packages/editor/build-module/components/inserter-sidebar/index.js
27809 /**
27810 * WordPress dependencies
27811 */
27812
27813
27814
27815
27816
27817
27818
27819
27820 /**
27821 * Internal dependencies
27822 */
27823
27824
27825
27826 const {
27827 PrivateInserterLibrary
27828 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
27829 function InserterSidebar() {
27830 const {
27831 blockSectionRootClientId,
27832 inserterSidebarToggleRef,
27833 inserter,
27834 showMostUsedBlocks,
27835 sidebarIsOpened
27836 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27837 const {
27838 getInserterSidebarToggleRef,
27839 getInserter,
27840 isPublishSidebarOpened
27841 } = unlock(select(store_store));
27842 const {
27843 getBlockRootClientId,
27844 isZoomOut,
27845 getSectionRootClientId
27846 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
27847 const {
27848 get
27849 } = select(external_wp_preferences_namespaceObject.store);
27850 const {
27851 getActiveComplementaryArea
27852 } = select(store);
27853 const getBlockSectionRootClientId = () => {
27854 if (isZoomOut()) {
27855 const sectionRootClientId = getSectionRootClientId();
27856 if (sectionRootClientId) {
27857 return sectionRootClientId;
27858 }
27859 }
27860 return getBlockRootClientId();
27861 };
27862 return {
27863 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
27864 inserter: getInserter(),
27865 showMostUsedBlocks: get('core', 'mostUsedBlocks'),
27866 blockSectionRootClientId: getBlockSectionRootClientId(),
27867 sidebarIsOpened: !!(getActiveComplementaryArea('core') || isPublishSidebarOpened())
27868 };
27869 }, []);
27870 const {
27871 setIsInserterOpened
27872 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
27873 const {
27874 disableComplementaryArea
27875 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27876 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
27877 const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
27878
27879 // When closing the inserter, focus should return to the toggle button.
27880 const closeInserterSidebar = (0,external_wp_element_namespaceObject.useCallback)(() => {
27881 setIsInserterOpened(false);
27882 inserterSidebarToggleRef.current?.focus();
27883 }, [inserterSidebarToggleRef, setIsInserterOpened]);
27884 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
27885 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
27886 event.preventDefault();
27887 closeInserterSidebar();
27888 }
27889 }, [closeInserterSidebar]);
27890 const inserterContents = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
27891 className: "editor-inserter-sidebar__content",
27892 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateInserterLibrary, {
27893 showMostUsedBlocks: showMostUsedBlocks,
27894 showInserterHelpPanel: true,
27895 shouldFocusBlock: isMobileViewport,
27896 rootClientId: blockSectionRootClientId,
27897 onSelect: inserter.onSelect,
27898 __experimentalInitialTab: inserter.tab,
27899 __experimentalInitialCategory: inserter.category,
27900 __experimentalFilterValue: inserter.filterValue,
27901 onPatternCategorySelection: sidebarIsOpened ? () => disableComplementaryArea('core') : undefined,
27902 ref: libraryRef,
27903 onClose: closeInserterSidebar
27904 })
27905 });
27906 return (
27907 /*#__PURE__*/
27908 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
27909 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
27910 onKeyDown: closeOnEscape,
27911 className: "editor-inserter-sidebar",
27912 children: inserterContents
27913 })
27914 );
27915 }
27916
27917 ;// ./packages/editor/build-module/components/list-view-sidebar/list-view-outline.js
27918 /**
27919 * WordPress dependencies
27920 */
27921
27922
27923
27924 /**
27925 * Internal dependencies
27926 */
27927
27928
27929
27930
27931
27932 function ListViewOutline() {
27933 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27934 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
27935 className: "editor-list-view-sidebar__outline",
27936 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
27937 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27938 children: (0,external_wp_i18n_namespaceObject.__)('Characters:')
27939 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27940 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
27941 })]
27942 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
27943 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27944 children: (0,external_wp_i18n_namespaceObject.__)('Words:')
27945 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
27946 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
27947 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27948 children: (0,external_wp_i18n_namespaceObject.__)('Time to read:')
27949 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
27950 })]
27951 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {})]
27952 });
27953 }
27954
27955 ;// ./packages/editor/build-module/components/list-view-sidebar/index.js
27956 /**
27957 * WordPress dependencies
27958 */
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968 /**
27969 * Internal dependencies
27970 */
27971
27972
27973
27974
27975 const {
27976 TabbedSidebar
27977 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
27978 function ListViewSidebar() {
27979 const {
27980 setIsListViewOpened
27981 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
27982 const {
27983 getListViewToggleRef
27984 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store));
27985
27986 // This hook handles focus when the sidebar first renders.
27987 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
27988
27989 // When closing the list view, focus should return to the toggle button.
27990 const closeListView = (0,external_wp_element_namespaceObject.useCallback)(() => {
27991 setIsListViewOpened(false);
27992 getListViewToggleRef().current?.focus();
27993 }, [getListViewToggleRef, setIsListViewOpened]);
27994 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
27995 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
27996 event.preventDefault();
27997 closeListView();
27998 }
27999 }, [closeListView]);
28000
28001 // Use internal state instead of a ref to make sure that the component
28002 // re-renders when the dropZoneElement updates.
28003 const [dropZoneElement, setDropZoneElement] = (0,external_wp_element_namespaceObject.useState)(null);
28004 // Tracks our current tab.
28005 const [tab, setTab] = (0,external_wp_element_namespaceObject.useState)('list-view');
28006
28007 // This ref refers to the sidebar as a whole.
28008 const sidebarRef = (0,external_wp_element_namespaceObject.useRef)();
28009 // This ref refers to the tab panel.
28010 const tabsRef = (0,external_wp_element_namespaceObject.useRef)();
28011 // This ref refers to the list view application area.
28012 const listViewRef = (0,external_wp_element_namespaceObject.useRef)();
28013
28014 // Must merge the refs together so focus can be handled properly in the next function.
28015 const listViewContainerRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([focusOnMountRef, listViewRef, setDropZoneElement]);
28016
28017 /*
28018 * Callback function to handle list view or outline focus.
28019 *
28020 * @param {string} currentTab The current tab. Either list view or outline.
28021 *
28022 * @return void
28023 */
28024 function handleSidebarFocus(currentTab) {
28025 // Tab panel focus.
28026 const tabPanelFocus = external_wp_dom_namespaceObject.focus.tabbable.find(tabsRef.current)[0];
28027 // List view tab is selected.
28028 if (currentTab === 'list-view') {
28029 // 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.
28030 const listViewApplicationFocus = external_wp_dom_namespaceObject.focus.tabbable.find(listViewRef.current)[0];
28031 const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : tabPanelFocus;
28032 listViewFocusArea.focus();
28033 // Outline tab is selected.
28034 } else {
28035 tabPanelFocus.focus();
28036 }
28037 }
28038 const handleToggleListViewShortcut = (0,external_wp_element_namespaceObject.useCallback)(() => {
28039 // If the sidebar has focus, it is safe to close.
28040 if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) {
28041 closeListView();
28042 } else {
28043 // If the list view or outline does not have focus, focus should be moved to it.
28044 handleSidebarFocus(tab);
28045 }
28046 }, [closeListView, tab]);
28047
28048 // This only fires when the sidebar is open because of the conditional rendering.
28049 // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
28050 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', handleToggleListViewShortcut);
28051 return (
28052 /*#__PURE__*/
28053 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
28054 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
28055 className: "editor-list-view-sidebar",
28056 onKeyDown: closeOnEscape,
28057 ref: sidebarRef,
28058 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TabbedSidebar, {
28059 tabs: [{
28060 name: 'list-view',
28061 title: (0,external_wp_i18n_namespaceObject._x)('List View', 'Post overview'),
28062 panel: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
28063 className: "editor-list-view-sidebar__list-view-container",
28064 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
28065 className: "editor-list-view-sidebar__list-view-panel-content",
28066 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
28067 dropZoneElement: dropZoneElement
28068 })
28069 })
28070 }),
28071 panelRef: listViewContainerRef
28072 }, {
28073 name: 'outline',
28074 title: (0,external_wp_i18n_namespaceObject._x)('Outline', 'Post overview'),
28075 panel: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
28076 className: "editor-list-view-sidebar__list-view-container",
28077 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewOutline, {})
28078 })
28079 }],
28080 onClose: closeListView,
28081 onSelect: tabName => setTab(tabName),
28082 defaultTabId: "list-view",
28083 ref: tabsRef,
28084 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close')
28085 })
28086 })
28087 );
28088 }
28089
28090 ;// ./packages/editor/build-module/components/save-publish-panels/index.js
28091 /**
28092 * WordPress dependencies
28093 */
28094
28095
28096
28097
28098
28099 /**
28100 * Internal dependencies
28101 */
28102
28103
28104
28105
28106
28107
28108 const {
28109 Fill: save_publish_panels_Fill,
28110 Slot: save_publish_panels_Slot
28111 } = (0,external_wp_components_namespaceObject.createSlotFill)('ActionsPanel');
28112 const ActionsPanelFill = (/* unused pure expression or super */ null && (save_publish_panels_Fill));
28113 function SavePublishPanels({
28114 setEntitiesSavedStatesCallback,
28115 closeEntitiesSavedStates,
28116 isEntitiesSavedStatesOpen,
28117 forceIsDirtyPublishPanel
28118 }) {
28119 const {
28120 closePublishSidebar,
28121 togglePublishSidebar
28122 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
28123 const {
28124 publishSidebarOpened,
28125 isPublishable,
28126 isDirty,
28127 hasOtherEntitiesChanges
28128 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28129 const {
28130 isPublishSidebarOpened,
28131 isEditedPostPublishable,
28132 isCurrentPostPublished,
28133 isEditedPostDirty,
28134 hasNonPostEntityChanges
28135 } = select(store_store);
28136 const _hasOtherEntitiesChanges = hasNonPostEntityChanges();
28137 return {
28138 publishSidebarOpened: isPublishSidebarOpened(),
28139 isPublishable: !isCurrentPostPublished() && isEditedPostPublishable(),
28140 isDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),
28141 hasOtherEntitiesChanges: _hasOtherEntitiesChanges
28142 };
28143 }, []);
28144 const openEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => setEntitiesSavedStatesCallback(true), []);
28145
28146 // It is ok for these components to be unmounted when not in visual use.
28147 // We don't want more than one present at a time, decide which to render.
28148 let unmountableContent;
28149 if (publishSidebarOpened) {
28150 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_panel, {
28151 onClose: closePublishSidebar,
28152 forceIsDirty: forceIsDirtyPublishPanel,
28153 PrePublishExtension: plugin_pre_publish_panel.Slot,
28154 PostPublishExtension: plugin_post_publish_panel.Slot
28155 });
28156 } else if (isPublishable && !hasOtherEntitiesChanges) {
28157 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
28158 className: "editor-layout__toggle-publish-panel",
28159 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28160 __next40pxDefaultSize: true,
28161 variant: "secondary",
28162 onClick: togglePublishSidebar,
28163 "aria-expanded": false,
28164 children: (0,external_wp_i18n_namespaceObject.__)('Open publish panel')
28165 })
28166 });
28167 } else {
28168 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
28169 className: "editor-layout__toggle-entities-saved-states-panel",
28170 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28171 __next40pxDefaultSize: true,
28172 variant: "secondary",
28173 onClick: openEntitiesSavedStates,
28174 "aria-expanded": false,
28175 disabled: !isDirty,
28176 accessibleWhenDisabled: true,
28177 children: (0,external_wp_i18n_namespaceObject.__)('Open save panel')
28178 })
28179 });
28180 }
28181
28182 // Since EntitiesSavedStates controls its own panel, we can keep it
28183 // always mounted to retain its own component state (such as checkboxes).
28184 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28185 children: [isEntitiesSavedStatesOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStates, {
28186 close: closeEntitiesSavedStates
28187 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(save_publish_panels_Slot, {
28188 bubblesVirtually: true
28189 }), !isEntitiesSavedStatesOpen && unmountableContent]
28190 });
28191 }
28192
28193 ;// ./packages/editor/build-module/components/text-editor/index.js
28194 /**
28195 * WordPress dependencies
28196 */
28197
28198
28199
28200
28201
28202
28203 /**
28204 * Internal dependencies
28205 */
28206
28207
28208
28209
28210 function TextEditor({
28211 autoFocus = false
28212 }) {
28213 const {
28214 switchEditorMode
28215 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
28216 const {
28217 shortcut,
28218 isRichEditingEnabled
28219 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28220 const {
28221 getEditorSettings
28222 } = select(store_store);
28223 const {
28224 getShortcutRepresentation
28225 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
28226 return {
28227 shortcut: getShortcutRepresentation('core/editor/toggle-mode'),
28228 isRichEditingEnabled: getEditorSettings().richEditingEnabled
28229 };
28230 }, []);
28231 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
28232 (0,external_wp_element_namespaceObject.useEffect)(() => {
28233 if (autoFocus) {
28234 return;
28235 }
28236 titleRef?.current?.focus();
28237 }, [autoFocus]);
28238 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28239 className: "editor-text-editor",
28240 children: [isRichEditingEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28241 className: "editor-text-editor__toolbar",
28242 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
28243 children: (0,external_wp_i18n_namespaceObject.__)('Editing code')
28244 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28245 __next40pxDefaultSize: true,
28246 variant: "tertiary",
28247 onClick: () => switchEditorMode('visual'),
28248 shortcut: shortcut,
28249 children: (0,external_wp_i18n_namespaceObject.__)('Exit code editor')
28250 })]
28251 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28252 className: "editor-text-editor__body",
28253 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title_raw, {
28254 ref: titleRef
28255 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTextEditor, {})]
28256 })]
28257 });
28258 }
28259
28260 ;// ./packages/editor/build-module/components/visual-editor/edit-template-blocks-notification.js
28261 /**
28262 * WordPress dependencies
28263 */
28264
28265
28266
28267
28268
28269
28270 /**
28271 * Internal dependencies
28272 */
28273
28274
28275 /**
28276 * Component that:
28277 *
28278 * - Displays a 'Edit your template to edit this block' notification when the
28279 * user is focusing on editing page content and clicks on a disabled template
28280 * block.
28281 * - Displays a 'Edit your template to edit this block' dialog when the user
28282 * is focusing on editing page conetnt and double clicks on a disabled
28283 * template block.
28284 *
28285 * @param {Object} props
28286 * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block
28287 * editor iframe canvas.
28288 */
28289
28290 function EditTemplateBlocksNotification({
28291 contentRef
28292 }) {
28293 const {
28294 onNavigateToEntityRecord,
28295 templateId
28296 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28297 const {
28298 getEditorSettings,
28299 getCurrentTemplateId
28300 } = select(store_store);
28301 return {
28302 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
28303 templateId: getCurrentTemplateId()
28304 };
28305 }, []);
28306 const canEditTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_coreData_namespaceObject.store).canUser('create', {
28307 kind: 'postType',
28308 name: 'wp_template'
28309 }), []);
28310 const [isDialogOpen, setIsDialogOpen] = (0,external_wp_element_namespaceObject.useState)(false);
28311 (0,external_wp_element_namespaceObject.useEffect)(() => {
28312 const handleDblClick = event => {
28313 if (!canEditTemplate) {
28314 return;
28315 }
28316 if (!event.target.classList.contains('is-root-container') || event.target.dataset?.type === 'core/template-part') {
28317 return;
28318 }
28319 if (!event.defaultPrevented) {
28320 event.preventDefault();
28321 setIsDialogOpen(true);
28322 }
28323 };
28324 const canvas = contentRef.current;
28325 canvas?.addEventListener('dblclick', handleDblClick);
28326 return () => {
28327 canvas?.removeEventListener('dblclick', handleDblClick);
28328 };
28329 }, [contentRef, canEditTemplate]);
28330 if (!canEditTemplate) {
28331 return null;
28332 }
28333 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
28334 isOpen: isDialogOpen,
28335 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Edit template'),
28336 onConfirm: () => {
28337 setIsDialogOpen(false);
28338 onNavigateToEntityRecord({
28339 postId: templateId,
28340 postType: 'wp_template'
28341 });
28342 },
28343 onCancel: () => setIsDialogOpen(false),
28344 size: "medium",
28345 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?')
28346 });
28347 }
28348
28349 ;// ./packages/editor/build-module/components/resizable-editor/resize-handle.js
28350 /**
28351 * WordPress dependencies
28352 */
28353
28354
28355
28356
28357 const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.
28358
28359 function ResizeHandle({
28360 direction,
28361 resizeWidthBy
28362 }) {
28363 function handleKeyDown(event) {
28364 const {
28365 keyCode
28366 } = event;
28367 if (keyCode !== external_wp_keycodes_namespaceObject.LEFT && keyCode !== external_wp_keycodes_namespaceObject.RIGHT) {
28368 return;
28369 }
28370 event.preventDefault();
28371 if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.LEFT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.RIGHT) {
28372 resizeWidthBy(DELTA_DISTANCE);
28373 } else if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.RIGHT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.LEFT) {
28374 resizeWidthBy(-DELTA_DISTANCE);
28375 }
28376 }
28377 const resizeHandleVariants = {
28378 active: {
28379 opacity: 1,
28380 scaleY: 1.3
28381 }
28382 };
28383 const resizableHandleHelpId = `resizable-editor__resize-help-${direction}`;
28384 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28385 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Tooltip, {
28386 text: (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
28387 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.button, {
28388 className: `editor-resizable-editor__resize-handle is-${direction}`,
28389 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
28390 "aria-describedby": resizableHandleHelpId,
28391 onKeyDown: handleKeyDown,
28392 variants: resizeHandleVariants,
28393 whileFocus: "active",
28394 whileHover: "active",
28395 whileTap: "active",
28396 role: "separator",
28397 "aria-orientation": "vertical"
28398 }, "handle")
28399 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
28400 id: resizableHandleHelpId,
28401 children: (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.')
28402 })]
28403 });
28404 }
28405
28406 ;// ./packages/editor/build-module/components/resizable-editor/index.js
28407 /**
28408 * External dependencies
28409 */
28410
28411
28412 /**
28413 * WordPress dependencies
28414 */
28415
28416
28417
28418 /**
28419 * Internal dependencies
28420 */
28421
28422
28423 // Removes the inline styles in the drag handles.
28424
28425 const HANDLE_STYLES_OVERRIDE = {
28426 position: undefined,
28427 userSelect: undefined,
28428 cursor: undefined,
28429 width: undefined,
28430 height: undefined,
28431 top: undefined,
28432 right: undefined,
28433 bottom: undefined,
28434 left: undefined
28435 };
28436 function ResizableEditor({
28437 className,
28438 enableResizing,
28439 height,
28440 children
28441 }) {
28442 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)('100%');
28443 const resizableRef = (0,external_wp_element_namespaceObject.useRef)();
28444 const resizeWidthBy = (0,external_wp_element_namespaceObject.useCallback)(deltaPixels => {
28445 if (resizableRef.current) {
28446 setWidth(resizableRef.current.offsetWidth + deltaPixels);
28447 }
28448 }, []);
28449 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ResizableBox, {
28450 className: dist_clsx('editor-resizable-editor', className, {
28451 'is-resizable': enableResizing
28452 }),
28453 ref: api => {
28454 resizableRef.current = api?.resizable;
28455 },
28456 size: {
28457 width: enableResizing ? width : '100%',
28458 height: enableResizing && height ? height : '100%'
28459 },
28460 onResizeStop: (event, direction, element) => {
28461 setWidth(element.style.width);
28462 },
28463 minWidth: 300,
28464 maxWidth: "100%",
28465 maxHeight: "100%",
28466 enable: {
28467 left: enableResizing,
28468 right: enableResizing
28469 },
28470 showHandle: enableResizing
28471 // The editor is centered horizontally, resizing it only
28472 // moves half the distance. Hence double the ratio to correctly
28473 // align the cursor to the resizer handle.
28474 ,
28475 resizeRatio: 2,
28476 handleComponent: {
28477 left: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
28478 direction: "left",
28479 resizeWidthBy: resizeWidthBy
28480 }),
28481 right: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
28482 direction: "right",
28483 resizeWidthBy: resizeWidthBy
28484 })
28485 },
28486 handleClasses: undefined,
28487 handleStyles: {
28488 left: HANDLE_STYLES_OVERRIDE,
28489 right: HANDLE_STYLES_OVERRIDE
28490 },
28491 children: children
28492 });
28493 }
28494 /* harmony default export */ const resizable_editor = (ResizableEditor);
28495
28496 ;// ./packages/editor/build-module/components/visual-editor/use-select-nearest-editable-block.js
28497 /**
28498 * WordPress dependencies
28499 */
28500
28501
28502
28503
28504 /**
28505 * Internal dependencies
28506 */
28507
28508 const DISTANCE_THRESHOLD = 500;
28509 function clamp(value, min, max) {
28510 return Math.min(Math.max(value, min), max);
28511 }
28512 function distanceFromRect(x, y, rect) {
28513 const dx = x - clamp(x, rect.left, rect.right);
28514 const dy = y - clamp(y, rect.top, rect.bottom);
28515 return Math.sqrt(dx * dx + dy * dy);
28516 }
28517 function useSelectNearestEditableBlock({
28518 isEnabled = true
28519 } = {}) {
28520 const {
28521 getEnabledClientIdsTree,
28522 getBlockName,
28523 getBlockOrder
28524 } = unlock((0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store));
28525 const {
28526 selectBlock
28527 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
28528 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
28529 if (!isEnabled) {
28530 return;
28531 }
28532 const selectNearestEditableBlock = (x, y) => {
28533 const editableBlockClientIds = getEnabledClientIdsTree().flatMap(({
28534 clientId
28535 }) => {
28536 const blockName = getBlockName(clientId);
28537 if (blockName === 'core/template-part') {
28538 return [];
28539 }
28540 if (blockName === 'core/post-content') {
28541 const innerBlocks = getBlockOrder(clientId);
28542 if (innerBlocks.length) {
28543 return innerBlocks;
28544 }
28545 }
28546 return [clientId];
28547 });
28548 let nearestDistance = Infinity,
28549 nearestClientId = null;
28550 for (const clientId of editableBlockClientIds) {
28551 const block = element.querySelector(`[data-block="${clientId}"]`);
28552 if (!block) {
28553 continue;
28554 }
28555 const rect = block.getBoundingClientRect();
28556 const distance = distanceFromRect(x, y, rect);
28557 if (distance < nearestDistance && distance < DISTANCE_THRESHOLD) {
28558 nearestDistance = distance;
28559 nearestClientId = clientId;
28560 }
28561 }
28562 if (nearestClientId) {
28563 selectBlock(nearestClientId);
28564 }
28565 };
28566 const handleClick = event => {
28567 const shouldSelect = event.target === element || event.target.classList.contains('is-root-container');
28568 if (shouldSelect) {
28569 selectNearestEditableBlock(event.clientX, event.clientY);
28570 }
28571 };
28572 element.addEventListener('click', handleClick);
28573 return () => element.removeEventListener('click', handleClick);
28574 }, [isEnabled]);
28575 }
28576
28577 ;// ./packages/editor/build-module/components/visual-editor/use-zoom-out-mode-exit.js
28578 /**
28579 * WordPress dependencies
28580 */
28581
28582
28583
28584
28585 /**
28586 * Internal dependencies
28587 */
28588
28589
28590 /**
28591 * Allows Zoom Out mode to be exited by double clicking in the selected block.
28592 */
28593 function useZoomOutModeExit() {
28594 const {
28595 getSettings,
28596 isZoomOut
28597 } = unlock((0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store));
28598 const {
28599 resetZoomLevel
28600 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store));
28601 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
28602 function onDoubleClick(event) {
28603 if (!isZoomOut()) {
28604 return;
28605 }
28606 if (!event.defaultPrevented) {
28607 event.preventDefault();
28608 const {
28609 __experimentalSetIsInserterOpened
28610 } = getSettings();
28611 if (typeof __experimentalSetIsInserterOpened === 'function') {
28612 __experimentalSetIsInserterOpened(false);
28613 }
28614 resetZoomLevel();
28615 }
28616 }
28617 node.addEventListener('dblclick', onDoubleClick);
28618 return () => {
28619 node.removeEventListener('dblclick', onDoubleClick);
28620 };
28621 }, [getSettings, isZoomOut, resetZoomLevel]);
28622 }
28623
28624 ;// ./packages/editor/build-module/components/visual-editor/index.js
28625 /**
28626 * External dependencies
28627 */
28628
28629
28630 /**
28631 * WordPress dependencies
28632 */
28633
28634
28635
28636
28637
28638
28639
28640 /**
28641 * Internal dependencies
28642 */
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652 const {
28653 LayoutStyle,
28654 useLayoutClasses,
28655 useLayoutStyles,
28656 ExperimentalBlockCanvas: BlockCanvas,
28657 useFlashEditableBlocks
28658 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
28659
28660 /**
28661 * These post types have a special editor where they don't allow you to fill the title
28662 * and they don't apply the layout styles.
28663 */
28664 const visual_editor_DESIGN_POST_TYPES = [PATTERN_POST_TYPE, constants_TEMPLATE_POST_TYPE, NAVIGATION_POST_TYPE, constants_TEMPLATE_PART_POST_TYPE];
28665
28666 /**
28667 * Given an array of nested blocks, find the first Post Content
28668 * block inside it, recursing through any nesting levels,
28669 * and return its attributes.
28670 *
28671 * @param {Array} blocks A list of blocks.
28672 *
28673 * @return {Object | undefined} The Post Content block.
28674 */
28675 function getPostContentAttributes(blocks) {
28676 for (let i = 0; i < blocks.length; i++) {
28677 if (blocks[i].name === 'core/post-content') {
28678 return blocks[i].attributes;
28679 }
28680 if (blocks[i].innerBlocks.length) {
28681 const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks);
28682 if (nestedPostContent) {
28683 return nestedPostContent;
28684 }
28685 }
28686 }
28687 }
28688 function checkForPostContentAtRootLevel(blocks) {
28689 for (let i = 0; i < blocks.length; i++) {
28690 if (blocks[i].name === 'core/post-content') {
28691 return true;
28692 }
28693 }
28694 return false;
28695 }
28696 function VisualEditor({
28697 // Ideally as we unify post and site editors, we won't need these props.
28698 autoFocus,
28699 styles,
28700 disableIframe = false,
28701 iframeProps,
28702 contentRef,
28703 className
28704 }) {
28705 const [contentHeight, setContentHeight] = (0,external_wp_element_namespaceObject.useState)('');
28706 const effectContentHeight = (0,external_wp_compose_namespaceObject.useResizeObserver)(([entry]) => {
28707 setContentHeight(entry.borderBoxSize[0].blockSize);
28708 });
28709 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
28710 const {
28711 renderingMode,
28712 postContentAttributes,
28713 editedPostTemplate = {},
28714 wrapperBlockName,
28715 wrapperUniqueId,
28716 deviceType,
28717 isFocusedEntity,
28718 isDesignPostType,
28719 postType,
28720 isPreview
28721 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28722 const {
28723 getCurrentPostId,
28724 getCurrentPostType,
28725 getCurrentTemplateId,
28726 getEditorSettings,
28727 getRenderingMode,
28728 getDeviceType
28729 } = select(store_store);
28730 const {
28731 getPostType,
28732 getEditedEntityRecord
28733 } = select(external_wp_coreData_namespaceObject.store);
28734 const postTypeSlug = getCurrentPostType();
28735 const _renderingMode = getRenderingMode();
28736 let _wrapperBlockName;
28737 if (postTypeSlug === PATTERN_POST_TYPE) {
28738 _wrapperBlockName = 'core/block';
28739 } else if (_renderingMode === 'post-only') {
28740 _wrapperBlockName = 'core/post-content';
28741 }
28742 const editorSettings = getEditorSettings();
28743 const supportsTemplateMode = editorSettings.supportsTemplateMode;
28744 const postTypeObject = getPostType(postTypeSlug);
28745 const currentTemplateId = getCurrentTemplateId();
28746 const template = currentTemplateId ? getEditedEntityRecord('postType', constants_TEMPLATE_POST_TYPE, currentTemplateId) : undefined;
28747 return {
28748 renderingMode: _renderingMode,
28749 postContentAttributes: editorSettings.postContentAttributes,
28750 isDesignPostType: visual_editor_DESIGN_POST_TYPES.includes(postTypeSlug),
28751 // Post template fetch returns a 404 on classic themes, which
28752 // messes with e2e tests, so check it's a block theme first.
28753 editedPostTemplate: postTypeObject?.viewable && supportsTemplateMode ? template : undefined,
28754 wrapperBlockName: _wrapperBlockName,
28755 wrapperUniqueId: getCurrentPostId(),
28756 deviceType: getDeviceType(),
28757 isFocusedEntity: !!editorSettings.onNavigateToPreviousEntityRecord,
28758 postType: postTypeSlug,
28759 isPreview: editorSettings.isPreviewMode
28760 };
28761 }, []);
28762 const {
28763 isCleanNewPost
28764 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
28765 const {
28766 hasRootPaddingAwareAlignments,
28767 themeHasDisabledLayoutStyles,
28768 themeSupportsLayout,
28769 isZoomedOut
28770 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28771 const {
28772 getSettings,
28773 isZoomOut: _isZoomOut
28774 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
28775 const _settings = getSettings();
28776 return {
28777 themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
28778 themeSupportsLayout: _settings.supportsLayout,
28779 hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
28780 isZoomedOut: _isZoomOut()
28781 };
28782 }, []);
28783 const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType);
28784 const [globalLayoutSettings] = (0,external_wp_blockEditor_namespaceObject.useSettings)('layout');
28785
28786 // fallbackLayout is used if there is no Post Content,
28787 // and for Post Title.
28788 const fallbackLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
28789 if (renderingMode !== 'post-only' || isDesignPostType) {
28790 return {
28791 type: 'default'
28792 };
28793 }
28794 if (themeSupportsLayout) {
28795 // We need to ensure support for wide and full alignments,
28796 // so we add the constrained type.
28797 return {
28798 ...globalLayoutSettings,
28799 type: 'constrained'
28800 };
28801 }
28802 // Set default layout for classic themes so all alignments are supported.
28803 return {
28804 type: 'default'
28805 };
28806 }, [renderingMode, themeSupportsLayout, globalLayoutSettings, isDesignPostType]);
28807 const newestPostContentAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => {
28808 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) {
28809 return postContentAttributes;
28810 }
28811 // When in template editing mode, we can access the blocks directly.
28812 if (editedPostTemplate?.blocks) {
28813 return getPostContentAttributes(editedPostTemplate?.blocks);
28814 }
28815 // If there are no blocks, we have to parse the content string.
28816 // Best double-check it's a string otherwise the parse function gets unhappy.
28817 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
28818 return getPostContentAttributes((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || {};
28819 }, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]);
28820 const hasPostContentAtRootLevel = (0,external_wp_element_namespaceObject.useMemo)(() => {
28821 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
28822 return false;
28823 }
28824 // When in template editing mode, we can access the blocks directly.
28825 if (editedPostTemplate?.blocks) {
28826 return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
28827 }
28828 // If there are no blocks, we have to parse the content string.
28829 // Best double-check it's a string otherwise the parse function gets unhappy.
28830 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
28831 return checkForPostContentAtRootLevel((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || false;
28832 }, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
28833 const {
28834 layout = {},
28835 align = ''
28836 } = newestPostContentAttributes || {};
28837 const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content');
28838 const blockListLayoutClass = dist_clsx({
28839 'is-layout-flow': !themeSupportsLayout
28840 }, themeSupportsLayout && postContentLayoutClasses, align && `align${align}`);
28841 const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container');
28842
28843 // Update type for blocks using legacy layouts.
28844 const postContentLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
28845 return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? {
28846 ...globalLayoutSettings,
28847 ...layout,
28848 type: 'constrained'
28849 } : {
28850 ...globalLayoutSettings,
28851 ...layout,
28852 type: 'default'
28853 };
28854 }, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]);
28855
28856 // If there is a Post Content block we use its layout for the block list;
28857 // if not, this must be a classic theme, in which case we use the fallback layout.
28858 const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
28859 const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
28860 const observeTypingRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)();
28861 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
28862 (0,external_wp_element_namespaceObject.useEffect)(() => {
28863 if (!autoFocus || !isCleanNewPost()) {
28864 return;
28865 }
28866 titleRef?.current?.focus();
28867 }, [autoFocus, isCleanNewPost]);
28868
28869 // Add some styles for alignwide/alignfull Post Content and its children.
28870 const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
28871 .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
28872 .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
28873 .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
28874 const forceFullHeight = postType === NAVIGATION_POST_TYPE;
28875 const enableResizing = [NAVIGATION_POST_TYPE, constants_TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE].includes(postType) &&
28876 // Disable in previews / view mode.
28877 !isPreview &&
28878 // Disable resizing in mobile viewport.
28879 !isMobileViewport &&
28880 // Dsiable resizing in zoomed-out mode.
28881 !isZoomedOut;
28882 const iframeStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
28883 return [...(styles !== null && styles !== void 0 ? styles : []), {
28884 // Ensures margins of children are contained so that the body background paints behind them.
28885 // Otherwise, the background of html (when zoomed out) would show there and appear broken. It’s
28886 // important mostly for post-only views yet conceivably an issue in templated views too.
28887 css: `:where(.block-editor-iframe__body){display:flow-root;}.is-root-container{display:flow-root;${
28888 // Some themes will have `min-height: 100vh` for the root container,
28889 // which isn't a requirement in auto resize mode.
28890 enableResizing ? 'min-height:0!important;' : ''}}`
28891 }];
28892 }, [styles, enableResizing]);
28893 const localRef = (0,external_wp_element_namespaceObject.useRef)();
28894 const typewriterRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypewriter)();
28895 contentRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([localRef, contentRef, renderingMode === 'post-only' ? typewriterRef : null, useFlashEditableBlocks({
28896 isEnabled: renderingMode === 'template-locked'
28897 }), useSelectNearestEditableBlock({
28898 isEnabled: renderingMode === 'template-locked'
28899 }), useZoomOutModeExit(),
28900 // Avoid resize listeners when not needed, these will trigger
28901 // unnecessary re-renders when animating the iframe width.
28902 enableResizing ? effectContentHeight : null]);
28903 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
28904 className: dist_clsx('editor-visual-editor',
28905 // this class is here for backward compatibility reasons.
28906 'edit-post-visual-editor', className, {
28907 'has-padding': isFocusedEntity || enableResizing,
28908 'is-resizable': enableResizing,
28909 'is-iframed': !disableIframe
28910 }),
28911 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(resizable_editor, {
28912 enableResizing: enableResizing,
28913 height: contentHeight && !forceFullHeight ? contentHeight : '100%',
28914 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockCanvas, {
28915 shouldIframe: !disableIframe,
28916 contentRef: contentRef,
28917 styles: iframeStyles,
28918 height: "100%",
28919 iframeProps: {
28920 ...iframeProps,
28921 style: {
28922 ...iframeProps?.style,
28923 ...deviceStyles
28924 }
28925 },
28926 children: [themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28927 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
28928 selector: ".editor-visual-editor__post-title-wrapper",
28929 layout: fallbackLayout
28930 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
28931 selector: ".block-editor-block-list__layout.is-root-container",
28932 layout: postEditorLayout
28933 }), align && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
28934 css: alignCSS
28935 }), postContentLayoutStyles && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
28936 layout: postContentLayout,
28937 css: postContentLayoutStyles
28938 })]
28939 }), renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
28940 className: dist_clsx('editor-visual-editor__post-title-wrapper',
28941 // The following class is only here for backward comapatibility
28942 // some themes might be using it to style the post title.
28943 'edit-post-visual-editor__post-title-wrapper', {
28944 'has-global-padding': hasRootPaddingAwareAlignments
28945 }),
28946 contentEditable: false,
28947 ref: observeTypingRef,
28948 style: {
28949 // This is using inline styles
28950 // so it's applied for both iframed and non iframed editors.
28951 marginTop: '4rem'
28952 },
28953 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title, {
28954 ref: titleRef
28955 })
28956 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_blockEditor_namespaceObject.RecursionProvider, {
28957 blockName: wrapperBlockName,
28958 uniqueId: wrapperUniqueId,
28959 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockList, {
28960 className: dist_clsx('is-' + deviceType.toLowerCase() + '-preview', renderingMode !== 'post-only' || isDesignPostType ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
28961 ),
28962 layout: blockListLayout,
28963 dropZoneElement:
28964 // When iframed, pass in the html element of the iframe to
28965 // ensure the drop zone extends to the edges of the iframe.
28966 disableIframe ? localRef.current : localRef.current?.parentNode,
28967 __unstableDisableDropZone:
28968 // In template preview mode, disable drop zones at the root of the template.
28969 renderingMode === 'template-locked' ? true : false
28970 }), renderingMode === 'template-locked' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditTemplateBlocksNotification, {
28971 contentRef: localRef
28972 })]
28973 })]
28974 })
28975 })
28976 });
28977 }
28978 /* harmony default export */ const visual_editor = (VisualEditor);
28979
28980 ;// ./packages/editor/build-module/components/editor-interface/index.js
28981 /**
28982 * External dependencies
28983 */
28984
28985
28986 /**
28987 * WordPress dependencies
28988 */
28989
28990
28991
28992
28993
28994
28995
28996
28997 /**
28998 * Internal dependencies
28999 */
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011 const interfaceLabels = {
29012 /* translators: accessibility text for the editor top bar landmark region. */
29013 header: (0,external_wp_i18n_namespaceObject.__)('Editor top bar'),
29014 /* translators: accessibility text for the editor content landmark region. */
29015 body: (0,external_wp_i18n_namespaceObject.__)('Editor content'),
29016 /* translators: accessibility text for the editor settings landmark region. */
29017 sidebar: (0,external_wp_i18n_namespaceObject.__)('Editor settings'),
29018 /* translators: accessibility text for the editor publish landmark region. */
29019 actions: (0,external_wp_i18n_namespaceObject.__)('Editor publish'),
29020 /* translators: accessibility text for the editor footer landmark region. */
29021 footer: (0,external_wp_i18n_namespaceObject.__)('Editor footer')
29022 };
29023 function EditorInterface({
29024 className,
29025 styles,
29026 children,
29027 forceIsDirty,
29028 contentRef,
29029 disableIframe,
29030 autoFocus,
29031 customSaveButton,
29032 customSavePanel,
29033 forceDisableBlockTools,
29034 title,
29035 iframeProps
29036 }) {
29037 const {
29038 mode,
29039 isRichEditingEnabled,
29040 isInserterOpened,
29041 isListViewOpened,
29042 isDistractionFree,
29043 isPreviewMode,
29044 showBlockBreadcrumbs,
29045 documentLabel,
29046 isZoomOut
29047 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29048 const {
29049 get
29050 } = select(external_wp_preferences_namespaceObject.store);
29051 const {
29052 getEditorSettings,
29053 getPostTypeLabel
29054 } = select(store_store);
29055 const editorSettings = getEditorSettings();
29056 const postTypeLabel = getPostTypeLabel();
29057 const {
29058 isZoomOut: _isZoomOut
29059 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
29060 return {
29061 mode: select(store_store).getEditorMode(),
29062 isRichEditingEnabled: editorSettings.richEditingEnabled,
29063 isInserterOpened: select(store_store).isInserterOpened(),
29064 isListViewOpened: select(store_store).isListViewOpened(),
29065 isDistractionFree: get('core', 'distractionFree'),
29066 isPreviewMode: editorSettings.isPreviewMode,
29067 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
29068 documentLabel:
29069 // translators: Default label for the Document in the Block Breadcrumb.
29070 postTypeLabel || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun, breadcrumb'),
29071 isZoomOut: _isZoomOut()
29072 };
29073 }, []);
29074 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
29075 const secondarySidebarLabel = isListViewOpened ? (0,external_wp_i18n_namespaceObject.__)('Document Overview') : (0,external_wp_i18n_namespaceObject.__)('Block Library');
29076
29077 // Local state for save panel.
29078 // Note 'truthy' callback implies an open panel.
29079 const [entitiesSavedStatesCallback, setEntitiesSavedStatesCallback] = (0,external_wp_element_namespaceObject.useState)(false);
29080 const closeEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(arg => {
29081 if (typeof entitiesSavedStatesCallback === 'function') {
29082 entitiesSavedStatesCallback(arg);
29083 }
29084 setEntitiesSavedStatesCallback(false);
29085 }, [entitiesSavedStatesCallback]);
29086 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(interface_skeleton, {
29087 isDistractionFree: isDistractionFree,
29088 className: dist_clsx('editor-editor-interface', className, {
29089 'is-entity-save-view-open': !!entitiesSavedStatesCallback,
29090 'is-distraction-free': isDistractionFree && !isPreviewMode
29091 }),
29092 labels: {
29093 ...interfaceLabels,
29094 secondarySidebar: secondarySidebarLabel
29095 },
29096 header: !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_header, {
29097 forceIsDirty: forceIsDirty,
29098 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
29099 customSaveButton: customSaveButton,
29100 forceDisableBlockTools: forceDisableBlockTools,
29101 title: title,
29102 isEditorIframed: !disableIframe
29103 }),
29104 editorNotices: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}),
29105 secondarySidebar: !isPreviewMode && mode === 'visual' && (isInserterOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InserterSidebar, {}) || isListViewOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewSidebar, {})),
29106 sidebar: !isPreviewMode && !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area.Slot, {
29107 scope: "core"
29108 }),
29109 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29110 children: [!isDistractionFree && !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(content_slot_fill.Slot, {
29111 children: ([editorCanvasView]) => editorCanvasView ? editorCanvasView : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29112 children: [!isPreviewMode && (mode === 'text' || !isRichEditingEnabled) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TextEditor
29113 // We should auto-focus the canvas (title) on load.
29114 // eslint-disable-next-line jsx-a11y/no-autofocus
29115 , {
29116 autoFocus: autoFocus
29117 }), !isPreviewMode && !isLargeViewport && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
29118 hideDragHandle: true
29119 }), (isPreviewMode || isRichEditingEnabled && mode === 'visual') && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(visual_editor, {
29120 styles: styles,
29121 contentRef: contentRef,
29122 disableIframe: disableIframe
29123 // We should auto-focus the canvas (title) on load.
29124 // eslint-disable-next-line jsx-a11y/no-autofocus
29125 ,
29126 autoFocus: autoFocus,
29127 iframeProps: iframeProps
29128 }), children]
29129 })
29130 })]
29131 }),
29132 footer: !isPreviewMode && !isDistractionFree && isLargeViewport && showBlockBreadcrumbs && isRichEditingEnabled && !isZoomOut && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
29133 rootLabelText: documentLabel
29134 }),
29135 actions: !isPreviewMode ? customSavePanel || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SavePublishPanels, {
29136 closeEntitiesSavedStates: closeEntitiesSavedStates,
29137 isEntitiesSavedStatesOpen: entitiesSavedStatesCallback,
29138 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
29139 forceIsDirtyPublishPanel: forceIsDirty
29140 }) : undefined
29141 });
29142 }
29143
29144 ;// ./packages/editor/build-module/components/pattern-overrides-panel/index.js
29145 /**
29146 * WordPress dependencies
29147 */
29148
29149
29150
29151 /**
29152 * Internal dependencies
29153 */
29154
29155
29156
29157 const {
29158 OverridesPanel
29159 } = unlock(external_wp_patterns_namespaceObject.privateApis);
29160 function PatternOverridesPanel() {
29161 const supportsPatternOverridesPanel = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType() === 'wp_block', []);
29162 if (!supportsPatternOverridesPanel) {
29163 return null;
29164 }
29165 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OverridesPanel, {});
29166 }
29167
29168 ;// ./packages/editor/build-module/components/post-actions/actions.js
29169 /**
29170 * WordPress dependencies
29171 */
29172
29173
29174
29175 /**
29176 * Internal dependencies
29177 */
29178
29179
29180
29181 function usePostActions({
29182 postType,
29183 onActionPerformed,
29184 context
29185 }) {
29186 const {
29187 defaultActions
29188 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29189 const {
29190 getEntityActions
29191 } = unlock(select(store_store));
29192 return {
29193 defaultActions: getEntityActions('postType', postType)
29194 };
29195 }, [postType]);
29196 const {
29197 registerPostTypeActions
29198 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
29199 (0,external_wp_element_namespaceObject.useEffect)(() => {
29200 registerPostTypeActions(postType);
29201 }, [registerPostTypeActions, postType]);
29202 return (0,external_wp_element_namespaceObject.useMemo)(() => {
29203 // Filter actions based on provided context. If not provided
29204 // all actions are returned. We'll have a single entry for getting the actions
29205 // and the consumer should provide the context to filter the actions, if needed.
29206 // Actions should also provide the `context` they support, if it's specific, to
29207 // compare with the provided context to get all the actions.
29208 // Right now the only supported context is `list`.
29209 const actions = defaultActions.filter(action => {
29210 if (!action.context) {
29211 return true;
29212 }
29213 return action.context === context;
29214 });
29215 if (onActionPerformed) {
29216 for (let i = 0; i < actions.length; ++i) {
29217 if (actions[i].callback) {
29218 const existingCallback = actions[i].callback;
29219 actions[i] = {
29220 ...actions[i],
29221 callback: (items, argsObject) => {
29222 existingCallback(items, {
29223 ...argsObject,
29224 onActionPerformed: _items => {
29225 if (argsObject?.onActionPerformed) {
29226 argsObject.onActionPerformed(_items);
29227 }
29228 onActionPerformed(actions[i].id, _items);
29229 }
29230 });
29231 }
29232 };
29233 }
29234 if (actions[i].RenderModal) {
29235 const ExistingRenderModal = actions[i].RenderModal;
29236 actions[i] = {
29237 ...actions[i],
29238 RenderModal: props => {
29239 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExistingRenderModal, {
29240 ...props,
29241 onActionPerformed: _items => {
29242 if (props.onActionPerformed) {
29243 props.onActionPerformed(_items);
29244 }
29245 onActionPerformed(actions[i].id, _items);
29246 }
29247 });
29248 }
29249 };
29250 }
29251 }
29252 }
29253 return actions;
29254 }, [defaultActions, onActionPerformed, context]);
29255 }
29256
29257 ;// ./packages/editor/build-module/components/post-actions/index.js
29258 /**
29259 * WordPress dependencies
29260 */
29261
29262
29263
29264
29265
29266
29267
29268 /**
29269 * Internal dependencies
29270 */
29271
29272
29273
29274 const {
29275 Menu,
29276 kebabCase
29277 } = unlock(external_wp_components_namespaceObject.privateApis);
29278 function PostActions({
29279 postType,
29280 postId,
29281 onActionPerformed
29282 }) {
29283 const [isActionsMenuOpen, setIsActionsMenuOpen] = (0,external_wp_element_namespaceObject.useState)(false);
29284 const {
29285 item,
29286 permissions
29287 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29288 const {
29289 getEditedEntityRecord,
29290 getEntityRecordPermissions
29291 } = unlock(select(external_wp_coreData_namespaceObject.store));
29292 return {
29293 item: getEditedEntityRecord('postType', postType, postId),
29294 permissions: getEntityRecordPermissions('postType', postType, postId)
29295 };
29296 }, [postId, postType]);
29297 const itemWithPermissions = (0,external_wp_element_namespaceObject.useMemo)(() => {
29298 return {
29299 ...item,
29300 permissions
29301 };
29302 }, [item, permissions]);
29303 const allActions = usePostActions({
29304 postType,
29305 onActionPerformed
29306 });
29307 const actions = (0,external_wp_element_namespaceObject.useMemo)(() => {
29308 return allActions.filter(action => {
29309 return !action.isEligible || action.isEligible(itemWithPermissions);
29310 });
29311 }, [allActions, itemWithPermissions]);
29312 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Menu, {
29313 open: isActionsMenuOpen,
29314 trigger: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
29315 size: "small",
29316 icon: more_vertical,
29317 label: (0,external_wp_i18n_namespaceObject.__)('Actions'),
29318 disabled: !actions.length,
29319 accessibleWhenDisabled: true,
29320 className: "editor-all-actions-button",
29321 onClick: () => setIsActionsMenuOpen(!isActionsMenuOpen)
29322 }),
29323 onOpenChange: setIsActionsMenuOpen,
29324 placement: "bottom-end",
29325 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionsDropdownMenuGroup, {
29326 actions: actions,
29327 item: itemWithPermissions,
29328 onClose: () => {
29329 setIsActionsMenuOpen(false);
29330 }
29331 })
29332 });
29333 }
29334
29335 // From now on all the functions on this file are copied as from the dataviews packages,
29336 // The editor packages should not be using the dataviews packages directly,
29337 // and the dataviews package should not be using the editor packages directly,
29338 // so duplicating the code here seems like the least bad option.
29339
29340 // Copied as is from packages/dataviews/src/item-actions.js
29341 function DropdownMenuItemTrigger({
29342 action,
29343 onClick,
29344 items
29345 }) {
29346 const label = typeof action.label === 'string' ? action.label : action.label(items);
29347 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Menu.Item, {
29348 onClick: onClick,
29349 hideOnClick: !action.RenderModal,
29350 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Menu.ItemLabel, {
29351 children: label
29352 })
29353 });
29354 }
29355
29356 // Copied as is from packages/dataviews/src/item-actions.js
29357 // With an added onClose prop.
29358 function ActionWithModal({
29359 action,
29360 item,
29361 ActionTrigger,
29362 onClose
29363 }) {
29364 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
29365 const actionTriggerProps = {
29366 action,
29367 onClick: () => setIsModalOpen(true),
29368 items: [item]
29369 };
29370 const {
29371 RenderModal,
29372 hideModalHeader
29373 } = action;
29374 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29375 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionTrigger, {
29376 ...actionTriggerProps
29377 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
29378 title: action.modalHeader || action.label,
29379 __experimentalHideHeader: !!hideModalHeader,
29380 onRequestClose: () => {
29381 setIsModalOpen(false);
29382 },
29383 overlayClassName: `editor-action-modal editor-action-modal__${kebabCase(action.id)}`,
29384 focusOnMount: "firstContentElement",
29385 size: "small",
29386 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RenderModal, {
29387 items: [item],
29388 closeModal: () => {
29389 setIsModalOpen(false);
29390 onClose();
29391 }
29392 })
29393 })]
29394 });
29395 }
29396
29397 // Copied as is from packages/dataviews/src/item-actions.js
29398 // With an added onClose prop.
29399 function ActionsDropdownMenuGroup({
29400 actions,
29401 item,
29402 onClose
29403 }) {
29404 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Menu.Group, {
29405 children: actions.map(action => {
29406 if (action.RenderModal) {
29407 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionWithModal, {
29408 action: action,
29409 item: item,
29410 ActionTrigger: DropdownMenuItemTrigger,
29411 onClose: onClose
29412 }, action.id);
29413 }
29414 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItemTrigger, {
29415 action: action,
29416 onClick: () => action.callback([item]),
29417 items: [item]
29418 }, action.id);
29419 })
29420 });
29421 }
29422
29423 ;// ./packages/editor/build-module/components/post-card-panel/index.js
29424 /**
29425 * WordPress dependencies
29426 */
29427
29428
29429
29430
29431
29432
29433 /**
29434 * Internal dependencies
29435 */
29436
29437
29438
29439
29440
29441
29442 function PostCardPanel({
29443 postType,
29444 postId,
29445 onActionPerformed
29446 }) {
29447 const {
29448 title,
29449 icon
29450 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29451 const {
29452 __experimentalGetTemplateInfo
29453 } = select(store_store);
29454 const {
29455 getEditedEntityRecord
29456 } = select(external_wp_coreData_namespaceObject.store);
29457 const _record = getEditedEntityRecord('postType', postType, postId);
29458 const _templateInfo = [constants_TEMPLATE_POST_TYPE, constants_TEMPLATE_PART_POST_TYPE].includes(postType) && __experimentalGetTemplateInfo(_record);
29459 return {
29460 title: _templateInfo?.title || _record?.title,
29461 icon: unlock(select(store_store)).getPostIcon(postType, {
29462 area: _record?.area
29463 })
29464 };
29465 }, [postId, postType]);
29466 const pageTypeBadge = usePageTypeBadge();
29467 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
29468 className: "editor-post-card-panel",
29469 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
29470 spacing: 2,
29471 className: "editor-post-card-panel__header",
29472 align: "flex-start",
29473 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
29474 className: "editor-post-card-panel__icon",
29475 icon: icon
29476 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalText, {
29477 numberOfLines: 2,
29478 truncate: true,
29479 className: "editor-post-card-panel__title",
29480 weight: 500,
29481 as: "h2",
29482 lineHeight: "20px",
29483 children: [title ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title) : (0,external_wp_i18n_namespaceObject.__)('No title'), pageTypeBadge && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
29484 className: "editor-post-card-panel__title-badge",
29485 children: pageTypeBadge
29486 })]
29487 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostActions, {
29488 postType: postType,
29489 postId: postId,
29490 onActionPerformed: onActionPerformed
29491 })]
29492 })
29493 });
29494 }
29495
29496 ;// ./packages/editor/build-module/components/post-content-information/index.js
29497 /**
29498 * WordPress dependencies
29499 */
29500
29501
29502
29503
29504
29505
29506
29507 /**
29508 * Internal dependencies
29509 */
29510
29511
29512
29513 // Taken from packages/editor/src/components/time-to-read/index.js.
29514
29515 const post_content_information_AVERAGE_READING_RATE = 189;
29516
29517 // This component renders the wordcount and reading time for the post.
29518 function PostContentInformation() {
29519 const {
29520 postContent
29521 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29522 const {
29523 getEditedPostAttribute,
29524 getCurrentPostType,
29525 getCurrentPostId
29526 } = select(store_store);
29527 const {
29528 canUser
29529 } = select(external_wp_coreData_namespaceObject.store);
29530 const {
29531 getEntityRecord
29532 } = select(external_wp_coreData_namespaceObject.store);
29533 const siteSettings = canUser('read', {
29534 kind: 'root',
29535 name: 'site'
29536 }) ? getEntityRecord('root', 'site') : undefined;
29537 const postType = getCurrentPostType();
29538 const _id = getCurrentPostId();
29539 const isPostsPage = +_id === siteSettings?.page_for_posts;
29540 const showPostContentInfo = !isPostsPage && ![constants_TEMPLATE_POST_TYPE, constants_TEMPLATE_PART_POST_TYPE].includes(postType);
29541 return {
29542 postContent: showPostContentInfo && getEditedPostAttribute('content')
29543 };
29544 }, []);
29545
29546 /*
29547 * translators: If your word count is based on single characters (e.g. East Asian characters),
29548 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
29549 * Do not translate into your own language.
29550 */
29551 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
29552 const wordsCounted = (0,external_wp_element_namespaceObject.useMemo)(() => postContent ? (0,external_wp_wordcount_namespaceObject.count)(postContent, wordCountType) : 0, [postContent, wordCountType]);
29553 if (!wordsCounted) {
29554 return null;
29555 }
29556 const readingTime = Math.round(wordsCounted / post_content_information_AVERAGE_READING_RATE);
29557 const wordsCountText = (0,external_wp_i18n_namespaceObject.sprintf)(
29558 // translators: %s: the number of words in the post.
29559 (0,external_wp_i18n_namespaceObject._n)('%s word', '%s words', wordsCounted), wordsCounted.toLocaleString());
29560 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. */
29561 (0,external_wp_i18n_namespaceObject._n)('%s minute', '%s minutes', readingTime), readingTime.toLocaleString());
29562 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
29563 className: "editor-post-content-information",
29564 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
29565 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.) */
29566 (0,external_wp_i18n_namespaceObject.__)('%1$s, %2$s read time.'), wordsCountText, minutesText)
29567 })
29568 });
29569 }
29570
29571 ;// ./packages/editor/build-module/components/post-format/panel.js
29572 /**
29573 * WordPress dependencies
29574 */
29575
29576
29577
29578
29579
29580
29581 /**
29582 * Internal dependencies
29583 */
29584
29585
29586
29587
29588
29589 /**
29590 * Renders the Post Author Panel component.
29591 *
29592 * @return {Component} The component to be rendered.
29593 */
29594
29595 function panel_PostFormat() {
29596 const {
29597 postFormat
29598 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29599 const {
29600 getEditedPostAttribute
29601 } = select(store_store);
29602 const _postFormat = getEditedPostAttribute('format');
29603 return {
29604 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard'
29605 };
29606 }, []);
29607 const activeFormat = POST_FORMATS.find(format => format.id === postFormat);
29608
29609 // Use internal state instead of a ref to make sure that the component
29610 // re-renders when the popover's anchor updates.
29611 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
29612 // Memoize popoverProps to avoid returning a new object every time.
29613 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
29614 // Anchor the popover to the middle of the entire row so that it doesn't
29615 // move around when the label changes.
29616 anchor: popoverAnchor,
29617 placement: 'left-start',
29618 offset: 36,
29619 shift: true
29620 }), [popoverAnchor]);
29621 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_check, {
29622 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
29623 label: (0,external_wp_i18n_namespaceObject.__)('Format'),
29624 ref: setPopoverAnchor,
29625 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
29626 popoverProps: popoverProps,
29627 contentClassName: "editor-post-format__dialog",
29628 focusOnMount: true,
29629 renderToggle: ({
29630 isOpen,
29631 onToggle
29632 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
29633 size: "compact",
29634 variant: "tertiary",
29635 "aria-expanded": isOpen,
29636 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
29637 // translators: %s: Current post format.
29638 (0,external_wp_i18n_namespaceObject.__)('Change format: %s'), activeFormat?.caption),
29639 onClick: onToggle,
29640 children: activeFormat?.caption
29641 }),
29642 renderContent: ({
29643 onClose
29644 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
29645 className: "editor-post-format__dialog-content",
29646 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
29647 title: (0,external_wp_i18n_namespaceObject.__)('Format'),
29648 onClose: onClose
29649 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormat, {})]
29650 })
29651 })
29652 })
29653 });
29654 }
29655 /* harmony default export */ const post_format_panel = (panel_PostFormat);
29656
29657 ;// ./packages/editor/build-module/components/post-last-edited-panel/index.js
29658 /**
29659 * WordPress dependencies
29660 */
29661
29662
29663
29664
29665
29666 /**
29667 * Internal dependencies
29668 */
29669
29670
29671 function PostLastEditedPanel() {
29672 const modified = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('modified'), []);
29673 const lastEditedText = modified && (0,external_wp_i18n_namespaceObject.sprintf)(
29674 // translators: %s: Human-readable time difference, e.g. "2 days ago".
29675 (0,external_wp_i18n_namespaceObject.__)('Last edited %s.'), (0,external_wp_date_namespaceObject.humanTimeDiff)(modified));
29676 if (!lastEditedText) {
29677 return null;
29678 }
29679 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
29680 className: "editor-post-last-edited-panel",
29681 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
29682 children: lastEditedText
29683 })
29684 });
29685 }
29686
29687 ;// ./packages/editor/build-module/components/post-panel-section/index.js
29688 /**
29689 * External dependencies
29690 */
29691
29692
29693 /**
29694 * WordPress dependencies
29695 */
29696
29697
29698 function PostPanelSection({
29699 className,
29700 children
29701 }) {
29702 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
29703 className: dist_clsx('editor-post-panel__section', className),
29704 children: children
29705 });
29706 }
29707 /* harmony default export */ const post_panel_section = (PostPanelSection);
29708
29709 ;// ./packages/editor/build-module/components/blog-title/index.js
29710 /**
29711 * WordPress dependencies
29712 */
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722 /**
29723 * Internal dependencies
29724 */
29725
29726
29727
29728
29729 const blog_title_EMPTY_OBJECT = {};
29730 function BlogTitle() {
29731 const {
29732 editEntityRecord
29733 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
29734 const {
29735 postsPageTitle,
29736 postsPageId,
29737 isTemplate,
29738 postSlug
29739 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29740 const {
29741 getEntityRecord,
29742 getEditedEntityRecord,
29743 canUser
29744 } = select(external_wp_coreData_namespaceObject.store);
29745 const siteSettings = canUser('read', {
29746 kind: 'root',
29747 name: 'site'
29748 }) ? getEntityRecord('root', 'site') : undefined;
29749 const _postsPageRecord = siteSettings?.page_for_posts ? getEditedEntityRecord('postType', 'page', siteSettings?.page_for_posts) : blog_title_EMPTY_OBJECT;
29750 const {
29751 getEditedPostAttribute,
29752 getCurrentPostType
29753 } = select(store_store);
29754 return {
29755 postsPageId: _postsPageRecord?.id,
29756 postsPageTitle: _postsPageRecord?.title,
29757 isTemplate: getCurrentPostType() === constants_TEMPLATE_POST_TYPE,
29758 postSlug: getEditedPostAttribute('slug')
29759 };
29760 }, []);
29761 // Use internal state instead of a ref to make sure that the component
29762 // re-renders when the popover's anchor updates.
29763 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
29764 // Memoize popoverProps to avoid returning a new object every time.
29765 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
29766 // Anchor the popover to the middle of the entire row so that it doesn't
29767 // move around when the label changes.
29768 anchor: popoverAnchor,
29769 placement: 'left-start',
29770 offset: 36,
29771 shift: true
29772 }), [popoverAnchor]);
29773 if (!isTemplate || !['home', 'index'].includes(postSlug) || !postsPageId) {
29774 return null;
29775 }
29776 const setPostsPageTitle = newValue => {
29777 editEntityRecord('postType', 'page', postsPageId, {
29778 title: newValue
29779 });
29780 };
29781 const decodedTitle = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postsPageTitle);
29782 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
29783 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
29784 ref: setPopoverAnchor,
29785 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
29786 popoverProps: popoverProps,
29787 contentClassName: "editor-blog-title-dropdown__content",
29788 focusOnMount: true,
29789 renderToggle: ({
29790 isOpen,
29791 onToggle
29792 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
29793 size: "compact",
29794 variant: "tertiary",
29795 "aria-expanded": isOpen,
29796 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
29797 // translators: %s: Current post link.
29798 (0,external_wp_i18n_namespaceObject.__)('Change blog title: %s'), decodedTitle),
29799 onClick: onToggle,
29800 children: decodedTitle
29801 }),
29802 renderContent: ({
29803 onClose
29804 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29805 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
29806 title: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
29807 onClose: onClose
29808 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
29809 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
29810 size: "__unstable-large",
29811 value: postsPageTitle,
29812 onChange: (0,external_wp_compose_namespaceObject.debounce)(setPostsPageTitle, 300),
29813 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
29814 help: (0,external_wp_i18n_namespaceObject.__)('Set the Posts Page title. Appears in search results, and when the page is shared on social media.'),
29815 hideLabelFromVision: true
29816 })]
29817 })
29818 })
29819 });
29820 }
29821
29822 ;// ./packages/editor/build-module/components/posts-per-page/index.js
29823 /**
29824 * WordPress dependencies
29825 */
29826
29827
29828
29829
29830
29831
29832
29833 /**
29834 * Internal dependencies
29835 */
29836
29837
29838
29839
29840 function PostsPerPage() {
29841 const {
29842 editEntityRecord
29843 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
29844 const {
29845 postsPerPage,
29846 isTemplate,
29847 postSlug
29848 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29849 const {
29850 getEditedPostAttribute,
29851 getCurrentPostType
29852 } = select(store_store);
29853 const {
29854 getEditedEntityRecord,
29855 canUser
29856 } = select(external_wp_coreData_namespaceObject.store);
29857 const siteSettings = canUser('read', {
29858 kind: 'root',
29859 name: 'site'
29860 }) ? getEditedEntityRecord('root', 'site') : undefined;
29861 return {
29862 isTemplate: getCurrentPostType() === constants_TEMPLATE_POST_TYPE,
29863 postSlug: getEditedPostAttribute('slug'),
29864 postsPerPage: siteSettings?.posts_per_page || 1
29865 };
29866 }, []);
29867 // Use internal state instead of a ref to make sure that the component
29868 // re-renders when the popover's anchor updates.
29869 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
29870 // Memoize popoverProps to avoid returning a new object every time.
29871 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
29872 // Anchor the popover to the middle of the entire row so that it doesn't
29873 // move around when the label changes.
29874 anchor: popoverAnchor,
29875 placement: 'left-start',
29876 offset: 36,
29877 shift: true
29878 }), [popoverAnchor]);
29879 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
29880 return null;
29881 }
29882 const setPostsPerPage = newValue => {
29883 editEntityRecord('root', 'site', undefined, {
29884 posts_per_page: newValue
29885 });
29886 };
29887 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
29888 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
29889 ref: setPopoverAnchor,
29890 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
29891 popoverProps: popoverProps,
29892 contentClassName: "editor-posts-per-page-dropdown__content",
29893 focusOnMount: true,
29894 renderToggle: ({
29895 isOpen,
29896 onToggle
29897 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
29898 size: "compact",
29899 variant: "tertiary",
29900 "aria-expanded": isOpen,
29901 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change posts per page'),
29902 onClick: onToggle,
29903 children: postsPerPage
29904 }),
29905 renderContent: ({
29906 onClose
29907 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29908 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
29909 title: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
29910 onClose: onClose
29911 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
29912 placeholder: 0,
29913 value: postsPerPage,
29914 size: "__unstable-large",
29915 spinControls: "custom",
29916 step: "1",
29917 min: "1",
29918 onChange: setPostsPerPage,
29919 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
29920 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.'),
29921 hideLabelFromVision: true
29922 })]
29923 })
29924 })
29925 });
29926 }
29927
29928 ;// ./packages/editor/build-module/components/site-discussion/index.js
29929 /**
29930 * WordPress dependencies
29931 */
29932
29933
29934
29935
29936
29937
29938
29939 /**
29940 * Internal dependencies
29941 */
29942
29943
29944
29945
29946 const site_discussion_COMMENT_OPTIONS = [{
29947 label: (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"'),
29948 value: 'open',
29949 description: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
29950 }, {
29951 label: (0,external_wp_i18n_namespaceObject.__)('Closed'),
29952 value: '',
29953 description: [(0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.'), (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')].join(' ')
29954 }];
29955 function SiteDiscussion() {
29956 const {
29957 editEntityRecord
29958 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
29959 const {
29960 allowCommentsOnNewPosts,
29961 isTemplate,
29962 postSlug
29963 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29964 const {
29965 getEditedPostAttribute,
29966 getCurrentPostType
29967 } = select(store_store);
29968 const {
29969 getEditedEntityRecord,
29970 canUser
29971 } = select(external_wp_coreData_namespaceObject.store);
29972 const siteSettings = canUser('read', {
29973 kind: 'root',
29974 name: 'site'
29975 }) ? getEditedEntityRecord('root', 'site') : undefined;
29976 return {
29977 isTemplate: getCurrentPostType() === constants_TEMPLATE_POST_TYPE,
29978 postSlug: getEditedPostAttribute('slug'),
29979 allowCommentsOnNewPosts: siteSettings?.default_comment_status || ''
29980 };
29981 }, []);
29982 // Use internal state instead of a ref to make sure that the component
29983 // re-renders when the popover's anchor updates.
29984 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
29985 // Memoize popoverProps to avoid returning a new object every time.
29986 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
29987 // Anchor the popover to the middle of the entire row so that it doesn't
29988 // move around when the label changes.
29989 anchor: popoverAnchor,
29990 placement: 'left-start',
29991 offset: 36,
29992 shift: true
29993 }), [popoverAnchor]);
29994 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
29995 return null;
29996 }
29997 const setAllowCommentsOnNewPosts = newValue => {
29998 editEntityRecord('root', 'site', undefined, {
29999 default_comment_status: newValue ? 'open' : null
30000 });
30001 };
30002 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
30003 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
30004 ref: setPopoverAnchor,
30005 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
30006 popoverProps: popoverProps,
30007 contentClassName: "editor-site-discussion-dropdown__content",
30008 focusOnMount: true,
30009 renderToggle: ({
30010 isOpen,
30011 onToggle
30012 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
30013 size: "compact",
30014 variant: "tertiary",
30015 "aria-expanded": isOpen,
30016 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion settings'),
30017 onClick: onToggle,
30018 children: allowCommentsOnNewPosts ? (0,external_wp_i18n_namespaceObject.__)('Comments open') : (0,external_wp_i18n_namespaceObject.__)('Comments closed')
30019 }),
30020 renderContent: ({
30021 onClose
30022 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
30023 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
30024 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
30025 onClose: onClose
30026 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
30027 spacing: 3,
30028 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
30029 children: (0,external_wp_i18n_namespaceObject.__)('Changes will apply to new posts only. Individual posts may override these settings.')
30030 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
30031 className: "editor-site-discussion__options",
30032 hideLabelFromVision: true,
30033 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
30034 options: site_discussion_COMMENT_OPTIONS,
30035 onChange: setAllowCommentsOnNewPosts,
30036 selected: allowCommentsOnNewPosts
30037 })]
30038 })]
30039 })
30040 })
30041 });
30042 }
30043
30044 ;// ./packages/editor/build-module/components/sidebar/post-summary.js
30045 /**
30046 * WordPress dependencies
30047 */
30048
30049
30050
30051 /**
30052 * Internal dependencies
30053 */
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077 /**
30078 * Module Constants
30079 */
30080
30081 const post_summary_PANEL_NAME = 'post-status';
30082 function PostSummary({
30083 onActionPerformed
30084 }) {
30085 const {
30086 isRemovedPostStatusPanel,
30087 postType,
30088 postId
30089 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30090 // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
30091 // not use isEditorPanelEnabled since this panel should not be disabled through the UI.
30092 const {
30093 isEditorPanelRemoved,
30094 getCurrentPostType,
30095 getCurrentPostId
30096 } = select(store_store);
30097 return {
30098 isRemovedPostStatusPanel: isEditorPanelRemoved(post_summary_PANEL_NAME),
30099 postType: getCurrentPostType(),
30100 postId: getCurrentPostId()
30101 };
30102 }, []);
30103 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_section, {
30104 className: "editor-post-summary",
30105 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info.Slot, {
30106 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
30107 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
30108 spacing: 4,
30109 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostCardPanel, {
30110 postType: postType,
30111 postId: postId,
30112 onActionPerformed: onActionPerformed
30113 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFeaturedImagePanel, {
30114 withPanelBody: false
30115 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostExcerptPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
30116 spacing: 1,
30117 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostContentInformation, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostLastEditedPanel, {})]
30118 }), !isRemovedPostStatusPanel && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
30119 spacing: 4,
30120 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
30121 spacing: 1,
30122 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, {})]
30123 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTrash, {
30124 onActionPerformed: onActionPerformed
30125 }), fills]
30126 })]
30127 })
30128 })
30129 })
30130 });
30131 }
30132
30133 ;// ./packages/editor/build-module/components/post-transform-panel/hooks.js
30134 /**
30135 * WordPress dependencies
30136 */
30137
30138
30139
30140
30141
30142
30143 /**
30144 * Internal dependencies
30145 */
30146
30147
30148 const {
30149 EXCLUDED_PATTERN_SOURCES,
30150 PATTERN_TYPES: hooks_PATTERN_TYPES
30151 } = unlock(external_wp_patterns_namespaceObject.privateApis);
30152 function injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet) {
30153 block.innerBlocks = block.innerBlocks.map(innerBlock => {
30154 return injectThemeAttributeInBlockTemplateContent(innerBlock, currentThemeStylesheet);
30155 });
30156 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
30157 block.attributes.theme = currentThemeStylesheet;
30158 }
30159 return block;
30160 }
30161
30162 /**
30163 * Filter all patterns and return only the ones that are compatible with the current template.
30164 *
30165 * @param {Array} patterns An array of patterns.
30166 * @param {Object} template The current template.
30167 * @return {Array} Array of patterns that are compatible with the current template.
30168 */
30169 function filterPatterns(patterns, template) {
30170 // Filter out duplicates.
30171 const filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex(item => currentItem.name === item.name);
30172
30173 // Filter out core/directory patterns not included in theme.json.
30174 const filterOutExcludedPatternSources = pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source);
30175
30176 // Looks for patterns that have the same template type as the current template,
30177 // or have a block type that matches the current template area.
30178 const filterCompatiblePatterns = pattern => pattern.templateTypes?.includes(template.slug) || pattern.blockTypes?.includes('core/template-part/' + template.area);
30179 return patterns.filter((pattern, index, items) => {
30180 return filterOutDuplicatesByName(pattern, index, items) && filterOutExcludedPatternSources(pattern) && filterCompatiblePatterns(pattern);
30181 });
30182 }
30183 function preparePatterns(patterns, currentThemeStylesheet) {
30184 return patterns.map(pattern => ({
30185 ...pattern,
30186 keywords: pattern.keywords || [],
30187 type: hooks_PATTERN_TYPES.theme,
30188 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, {
30189 __unstableSkipMigrationLogs: true
30190 }).map(block => injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet))
30191 }));
30192 }
30193 function useAvailablePatterns(template) {
30194 const {
30195 blockPatterns,
30196 restBlockPatterns,
30197 currentThemeStylesheet
30198 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30199 var _settings$__experimen;
30200 const {
30201 getEditorSettings
30202 } = select(store_store);
30203 const settings = getEditorSettings();
30204 return {
30205 blockPatterns: (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns,
30206 restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(),
30207 currentThemeStylesheet: select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet
30208 };
30209 }, []);
30210 return (0,external_wp_element_namespaceObject.useMemo)(() => {
30211 const mergedPatterns = [...(blockPatterns || []), ...(restBlockPatterns || [])];
30212 const filteredPatterns = filterPatterns(mergedPatterns, template);
30213 return preparePatterns(filteredPatterns, template, currentThemeStylesheet);
30214 }, [blockPatterns, restBlockPatterns, template, currentThemeStylesheet]);
30215 }
30216
30217 ;// ./packages/editor/build-module/components/post-transform-panel/index.js
30218 /**
30219 * WordPress dependencies
30220 */
30221
30222
30223
30224
30225
30226
30227
30228
30229 /**
30230 * Internal dependencies
30231 */
30232
30233
30234
30235
30236 function post_transform_panel_TemplatesList({
30237 availableTemplates,
30238 onSelect
30239 }) {
30240 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(availableTemplates);
30241 if (!availableTemplates || availableTemplates?.length === 0) {
30242 return null;
30243 }
30244 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
30245 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
30246 blockPatterns: availableTemplates,
30247 shownPatterns: shownTemplates,
30248 onClickPattern: onSelect,
30249 showTitlesAsTooltip: true
30250 });
30251 }
30252 function PostTransform() {
30253 const {
30254 record,
30255 postType,
30256 postId
30257 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30258 const {
30259 getCurrentPostType,
30260 getCurrentPostId
30261 } = select(store_store);
30262 const {
30263 getEditedEntityRecord
30264 } = select(external_wp_coreData_namespaceObject.store);
30265 const type = getCurrentPostType();
30266 const id = getCurrentPostId();
30267 return {
30268 postType: type,
30269 postId: id,
30270 record: getEditedEntityRecord('postType', type, id)
30271 };
30272 }, []);
30273 const {
30274 editEntityRecord
30275 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
30276 const availablePatterns = useAvailablePatterns(record);
30277 const onTemplateSelect = async selectedTemplate => {
30278 await editEntityRecord('postType', postType, postId, {
30279 blocks: selectedTemplate.blocks,
30280 content: (0,external_wp_blocks_namespaceObject.serialize)(selectedTemplate.blocks)
30281 });
30282 };
30283 if (!availablePatterns?.length) {
30284 return null;
30285 }
30286 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
30287 title: (0,external_wp_i18n_namespaceObject.__)('Design'),
30288 initialOpen: record.type === constants_TEMPLATE_PART_POST_TYPE,
30289 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_transform_panel_TemplatesList, {
30290 availableTemplates: availablePatterns,
30291 onSelect: onTemplateSelect
30292 })
30293 });
30294 }
30295 function PostTransformPanel() {
30296 const {
30297 postType
30298 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30299 const {
30300 getCurrentPostType
30301 } = select(store_store);
30302 return {
30303 postType: getCurrentPostType()
30304 };
30305 }, []);
30306 if (![constants_TEMPLATE_PART_POST_TYPE, constants_TEMPLATE_POST_TYPE].includes(postType)) {
30307 return null;
30308 }
30309 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTransform, {});
30310 }
30311
30312 ;// ./packages/editor/build-module/components/sidebar/constants.js
30313 const sidebars = {
30314 document: 'edit-post/document',
30315 block: 'edit-post/block'
30316 };
30317
30318 ;// ./packages/editor/build-module/components/sidebar/header.js
30319 /**
30320 * WordPress dependencies
30321 */
30322
30323
30324
30325
30326
30327 /**
30328 * Internal dependencies
30329 */
30330
30331
30332
30333
30334 const {
30335 Tabs
30336 } = unlock(external_wp_components_namespaceObject.privateApis);
30337 const SidebarHeader = (_, ref) => {
30338 const {
30339 documentLabel
30340 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30341 const {
30342 getPostTypeLabel
30343 } = select(store_store);
30344 return {
30345 documentLabel:
30346 // translators: Default label for the Document sidebar tab, not selected.
30347 getPostTypeLabel() || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun, sidebar')
30348 };
30349 }, []);
30350 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs.TabList, {
30351 ref: ref,
30352 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
30353 tabId: sidebars.document
30354 // Used for focus management in the SettingsSidebar component.
30355 ,
30356 "data-tab-id": sidebars.document,
30357 children: documentLabel
30358 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
30359 tabId: sidebars.block
30360 // Used for focus management in the SettingsSidebar component.
30361 ,
30362 "data-tab-id": sidebars.block,
30363 children: (0,external_wp_i18n_namespaceObject.__)('Block')
30364 })]
30365 });
30366 };
30367 /* harmony default export */ const sidebar_header = ((0,external_wp_element_namespaceObject.forwardRef)(SidebarHeader));
30368
30369 ;// ./packages/editor/build-module/components/template-content-panel/index.js
30370 /**
30371 * WordPress dependencies
30372 */
30373
30374
30375
30376
30377
30378
30379
30380
30381 /**
30382 * Internal dependencies
30383 */
30384
30385
30386
30387
30388 const {
30389 BlockQuickNavigation
30390 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
30391 const template_content_panel_POST_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
30392 const TEMPLATE_PART_BLOCK = 'core/template-part';
30393 function TemplateContentPanel() {
30394 const postContentBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_hooks_namespaceObject.applyFilters)('editor.postContentBlockTypes', template_content_panel_POST_CONTENT_BLOCK_TYPES), []);
30395 const {
30396 clientIds,
30397 postType,
30398 renderingMode
30399 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30400 const {
30401 getCurrentPostType,
30402 getPostBlocksByName,
30403 getRenderingMode
30404 } = unlock(select(store_store));
30405 const _postType = getCurrentPostType();
30406 return {
30407 postType: _postType,
30408 clientIds: getPostBlocksByName(constants_TEMPLATE_POST_TYPE === _postType ? TEMPLATE_PART_BLOCK : postContentBlockTypes),
30409 renderingMode: getRenderingMode()
30410 };
30411 }, [postContentBlockTypes]);
30412 const {
30413 enableComplementaryArea
30414 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
30415 if (renderingMode === 'post-only' && postType !== constants_TEMPLATE_POST_TYPE || clientIds.length === 0) {
30416 return null;
30417 }
30418 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
30419 title: (0,external_wp_i18n_namespaceObject.__)('Content'),
30420 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockQuickNavigation, {
30421 clientIds: clientIds,
30422 onSelect: () => {
30423 enableComplementaryArea('core', 'edit-post/document');
30424 }
30425 })
30426 });
30427 }
30428
30429 ;// ./packages/editor/build-module/components/template-part-content-panel/index.js
30430 /**
30431 * WordPress dependencies
30432 */
30433
30434
30435
30436
30437
30438
30439
30440 /**
30441 * Internal dependencies
30442 */
30443
30444
30445
30446
30447 const {
30448 BlockQuickNavigation: template_part_content_panel_BlockQuickNavigation
30449 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
30450 function TemplatePartContentPanelInner() {
30451 const blockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => {
30452 const {
30453 getBlockTypes
30454 } = select(external_wp_blocks_namespaceObject.store);
30455 return getBlockTypes();
30456 }, []);
30457 const themeBlockNames = (0,external_wp_element_namespaceObject.useMemo)(() => {
30458 return blockTypes.filter(blockType => {
30459 return blockType.category === 'theme';
30460 }).map(({
30461 name
30462 }) => name);
30463 }, [blockTypes]);
30464 const themeBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => {
30465 const {
30466 getBlocksByName
30467 } = select(external_wp_blockEditor_namespaceObject.store);
30468 return getBlocksByName(themeBlockNames);
30469 }, [themeBlockNames]);
30470 if (themeBlocks.length === 0) {
30471 return null;
30472 }
30473 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
30474 title: (0,external_wp_i18n_namespaceObject.__)('Content'),
30475 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(template_part_content_panel_BlockQuickNavigation, {
30476 clientIds: themeBlocks
30477 })
30478 });
30479 }
30480 function TemplatePartContentPanel() {
30481 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
30482 const {
30483 getCurrentPostType
30484 } = select(store_store);
30485 return getCurrentPostType();
30486 }, []);
30487 if (postType !== constants_TEMPLATE_PART_POST_TYPE) {
30488 return null;
30489 }
30490 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartContentPanelInner, {});
30491 }
30492
30493 ;// ./packages/editor/build-module/components/provider/use-auto-switch-editor-sidebars.js
30494 /**
30495 * WordPress dependencies
30496 */
30497
30498
30499
30500
30501
30502
30503 /**
30504 * This listener hook monitors for block selection and triggers the appropriate
30505 * sidebar state.
30506 */
30507 function useAutoSwitchEditorSidebars() {
30508 const {
30509 hasBlockSelection
30510 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30511 return {
30512 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
30513 };
30514 }, []);
30515 const {
30516 getActiveComplementaryArea
30517 } = (0,external_wp_data_namespaceObject.useSelect)(store);
30518 const {
30519 enableComplementaryArea
30520 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
30521 const {
30522 get: getPreference
30523 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_preferences_namespaceObject.store);
30524 (0,external_wp_element_namespaceObject.useEffect)(() => {
30525 const activeGeneralSidebar = getActiveComplementaryArea('core');
30526 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(activeGeneralSidebar);
30527 const isDistractionFree = getPreference('core', 'distractionFree');
30528 if (!isEditorSidebarOpened || isDistractionFree) {
30529 return;
30530 }
30531 if (hasBlockSelection) {
30532 enableComplementaryArea('core', 'edit-post/block');
30533 } else {
30534 enableComplementaryArea('core', 'edit-post/document');
30535 }
30536 }, [hasBlockSelection, getActiveComplementaryArea, enableComplementaryArea, getPreference]);
30537 }
30538 /* harmony default export */ const use_auto_switch_editor_sidebars = (useAutoSwitchEditorSidebars);
30539
30540 ;// ./packages/editor/build-module/components/sidebar/index.js
30541 /**
30542 * WordPress dependencies
30543 */
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553 /**
30554 * Internal dependencies
30555 */
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571 const {
30572 Tabs: sidebar_Tabs
30573 } = unlock(external_wp_components_namespaceObject.privateApis);
30574 const SIDEBAR_ACTIVE_BY_DEFAULT = external_wp_element_namespaceObject.Platform.select({
30575 web: true,
30576 native: false
30577 });
30578 const SidebarContent = ({
30579 tabName,
30580 keyboardShortcut,
30581 onActionPerformed,
30582 extraPanels
30583 }) => {
30584 const tabListRef = (0,external_wp_element_namespaceObject.useRef)(null);
30585 // Because `PluginSidebar` renders a `ComplementaryArea`, we
30586 // need to forward the `Tabs` context so it can be passed through the
30587 // underlying slot/fill.
30588 const tabsContextValue = (0,external_wp_element_namespaceObject.useContext)(sidebar_Tabs.Context);
30589
30590 // This effect addresses a race condition caused by tabbing from the last
30591 // block in the editor into the settings sidebar. Without this effect, the
30592 // selected tab and browser focus can become separated in an unexpected way
30593 // (e.g the "block" tab is focused, but the "post" tab is selected).
30594 (0,external_wp_element_namespaceObject.useEffect)(() => {
30595 const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []);
30596 const selectedTabElement = tabsElements.find(
30597 // We are purposefully using a custom `data-tab-id` attribute here
30598 // because we don't want rely on any assumptions about `Tabs`
30599 // component internals.
30600 element => element.getAttribute('data-tab-id') === tabName);
30601 const activeElement = selectedTabElement?.ownerDocument.activeElement;
30602 const tabsHasFocus = tabsElements.some(element => {
30603 return activeElement && activeElement.id === element.id;
30604 });
30605 if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
30606 selectedTabElement?.focus();
30607 }
30608 }, [tabName]);
30609 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginSidebar, {
30610 identifier: tabName,
30611 header: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.Context.Provider, {
30612 value: tabsContextValue,
30613 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_header, {
30614 ref: tabListRef
30615 })
30616 }),
30617 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Settings')
30618 // This classname is added so we can apply a corrective negative
30619 // margin to the panel.
30620 // see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
30621 ,
30622 className: "editor-sidebar__panel",
30623 headerClassName: "editor-sidebar__panel-tabs",
30624 title: /* translators: button label text should, if possible, be under 16 characters. */
30625 (0,external_wp_i18n_namespaceObject._x)('Settings', 'sidebar button label'),
30626 toggleShortcut: keyboardShortcut,
30627 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
30628 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
30629 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.Context.Provider, {
30630 value: tabsContextValue,
30631 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.TabPanel, {
30632 tabId: sidebars.document,
30633 focusable: false,
30634 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSummary, {
30635 onActionPerformed: onActionPerformed
30636 }), /*#__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)(post_taxonomies_panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesPanel, {}), extraPanels]
30637 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.TabPanel, {
30638 tabId: sidebars.block,
30639 focusable: false,
30640 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockInspector, {})
30641 })]
30642 })
30643 });
30644 };
30645 const Sidebar = ({
30646 extraPanels,
30647 onActionPerformed
30648 }) => {
30649 use_auto_switch_editor_sidebars();
30650 const {
30651 tabName,
30652 keyboardShortcut,
30653 showSummary
30654 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30655 const shortcut = select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-sidebar');
30656 const sidebar = select(store).getActiveComplementaryArea('core');
30657 const _isEditorSidebarOpened = [sidebars.block, sidebars.document].includes(sidebar);
30658 let _tabName = sidebar;
30659 if (!_isEditorSidebarOpened) {
30660 _tabName = !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart() ? sidebars.block : sidebars.document;
30661 }
30662 return {
30663 tabName: _tabName,
30664 keyboardShortcut: shortcut,
30665 showSummary: ![constants_TEMPLATE_POST_TYPE, constants_TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE].includes(select(store_store).getCurrentPostType())
30666 };
30667 }, []);
30668 const {
30669 enableComplementaryArea
30670 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
30671 const onTabSelect = (0,external_wp_element_namespaceObject.useCallback)(newSelectedTabId => {
30672 if (!!newSelectedTabId) {
30673 enableComplementaryArea('core', newSelectedTabId);
30674 }
30675 }, [enableComplementaryArea]);
30676 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs, {
30677 selectedTabId: tabName,
30678 onSelect: onTabSelect,
30679 selectOnMove: false,
30680 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SidebarContent, {
30681 tabName: tabName,
30682 keyboardShortcut: keyboardShortcut,
30683 showSummary: showSummary,
30684 onActionPerformed: onActionPerformed,
30685 extraPanels: extraPanels
30686 })
30687 });
30688 };
30689 /* harmony default export */ const components_sidebar = (Sidebar);
30690
30691 ;// ./packages/editor/build-module/components/editor/index.js
30692 /**
30693 * WordPress dependencies
30694 */
30695
30696
30697
30698
30699
30700 /**
30701 * Internal dependencies
30702 */
30703
30704
30705
30706
30707
30708 function Editor({
30709 postType,
30710 postId,
30711 templateId,
30712 settings,
30713 children,
30714 initialEdits,
30715 // This could be part of the settings.
30716 onActionPerformed,
30717 // The following abstractions are not ideal but necessary
30718 // to account for site editor and post editor differences for now.
30719 extraContent,
30720 extraSidebarPanels,
30721 ...props
30722 }) {
30723 const {
30724 post,
30725 template,
30726 hasLoadedPost
30727 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30728 const {
30729 getEntityRecord,
30730 hasFinishedResolution
30731 } = select(external_wp_coreData_namespaceObject.store);
30732 return {
30733 post: getEntityRecord('postType', postType, postId),
30734 template: templateId ? getEntityRecord('postType', constants_TEMPLATE_POST_TYPE, templateId) : undefined,
30735 hasLoadedPost: hasFinishedResolution('getEntityRecord', ['postType', postType, postId])
30736 };
30737 }, [postType, postId, templateId]);
30738 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
30739 children: [hasLoadedPost && !post && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
30740 status: "warning",
30741 isDismissible: false,
30742 children: (0,external_wp_i18n_namespaceObject.__)("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")
30743 }), !!post && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ExperimentalEditorProvider, {
30744 post: post,
30745 __unstableTemplate: template,
30746 settings: settings,
30747 initialEdits: initialEdits,
30748 useSubRegistry: false,
30749 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditorInterface, {
30750 ...props,
30751 children: extraContent
30752 }), children, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_sidebar, {
30753 onActionPerformed: onActionPerformed,
30754 extraPanels: extraSidebarPanels
30755 })]
30756 })]
30757 });
30758 }
30759 /* harmony default export */ const editor = (Editor);
30760
30761 ;// ./packages/editor/build-module/components/preferences-modal/enable-publish-sidebar.js
30762 /**
30763 * WordPress dependencies
30764 */
30765
30766
30767
30768
30769 /**
30770 * Internal dependencies
30771 */
30772
30773
30774 const {
30775 PreferenceBaseOption: enable_publish_sidebar_PreferenceBaseOption
30776 } = unlock(external_wp_preferences_namespaceObject.privateApis);
30777 /* harmony default export */ const enable_publish_sidebar = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => ({
30778 isChecked: select(store_store).isPublishSidebarEnabled()
30779 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
30780 const {
30781 enablePublishSidebar,
30782 disablePublishSidebar
30783 } = dispatch(store_store);
30784 return {
30785 onChange: isEnabled => isEnabled ? enablePublishSidebar() : disablePublishSidebar()
30786 };
30787 }))(enable_publish_sidebar_PreferenceBaseOption));
30788
30789 ;// ./packages/editor/build-module/components/block-manager/checklist.js
30790 /**
30791 * WordPress dependencies
30792 */
30793
30794
30795
30796 function BlockTypesChecklist({
30797 blockTypes,
30798 value,
30799 onItemChange
30800 }) {
30801 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
30802 className: "editor-block-manager__checklist",
30803 children: blockTypes.map(blockType => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
30804 className: "editor-block-manager__checklist-item",
30805 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
30806 __nextHasNoMarginBottom: true,
30807 label: blockType.title,
30808 checked: value.includes(blockType.name),
30809 onChange: (...args) => onItemChange(blockType.name, ...args)
30810 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
30811 icon: blockType.icon
30812 })]
30813 }, blockType.name))
30814 });
30815 }
30816 /* harmony default export */ const checklist = (BlockTypesChecklist);
30817
30818 ;// ./packages/editor/build-module/components/block-manager/category.js
30819 /**
30820 * WordPress dependencies
30821 */
30822
30823
30824
30825
30826
30827
30828 /**
30829 * Internal dependencies
30830 */
30831
30832
30833
30834
30835 function BlockManagerCategory({
30836 title,
30837 blockTypes
30838 }) {
30839 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockManagerCategory);
30840 const {
30841 allowedBlockTypes,
30842 hiddenBlockTypes
30843 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30844 const {
30845 getEditorSettings
30846 } = select(store_store);
30847 const {
30848 get
30849 } = select(external_wp_preferences_namespaceObject.store);
30850 return {
30851 allowedBlockTypes: getEditorSettings().allowedBlockTypes,
30852 hiddenBlockTypes: get('core', 'hiddenBlockTypes')
30853 };
30854 }, []);
30855 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
30856 if (allowedBlockTypes === true) {
30857 return blockTypes;
30858 }
30859 return blockTypes.filter(({
30860 name
30861 }) => {
30862 return allowedBlockTypes?.includes(name);
30863 });
30864 }, [allowedBlockTypes, blockTypes]);
30865 const {
30866 showBlockTypes,
30867 hideBlockTypes
30868 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
30869 const toggleVisible = (0,external_wp_element_namespaceObject.useCallback)((blockName, nextIsChecked) => {
30870 if (nextIsChecked) {
30871 showBlockTypes(blockName);
30872 } else {
30873 hideBlockTypes(blockName);
30874 }
30875 }, [showBlockTypes, hideBlockTypes]);
30876 const toggleAllVisible = (0,external_wp_element_namespaceObject.useCallback)(nextIsChecked => {
30877 const blockNames = blockTypes.map(({
30878 name
30879 }) => name);
30880 if (nextIsChecked) {
30881 showBlockTypes(blockNames);
30882 } else {
30883 hideBlockTypes(blockNames);
30884 }
30885 }, [blockTypes, showBlockTypes, hideBlockTypes]);
30886 if (!filteredBlockTypes.length) {
30887 return null;
30888 }
30889 const checkedBlockNames = filteredBlockTypes.map(({
30890 name
30891 }) => name).filter(type => !(hiddenBlockTypes !== null && hiddenBlockTypes !== void 0 ? hiddenBlockTypes : []).includes(type));
30892 const titleId = 'editor-block-manager__category-title-' + instanceId;
30893 const isAllChecked = checkedBlockNames.length === filteredBlockTypes.length;
30894 const isIndeterminate = !isAllChecked && checkedBlockNames.length > 0;
30895 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30896 role: "group",
30897 "aria-labelledby": titleId,
30898 className: "editor-block-manager__category",
30899 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
30900 __nextHasNoMarginBottom: true,
30901 checked: isAllChecked,
30902 onChange: toggleAllVisible,
30903 className: "editor-block-manager__category-title",
30904 indeterminate: isIndeterminate,
30905 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
30906 id: titleId,
30907 children: title
30908 })
30909 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(checklist, {
30910 blockTypes: filteredBlockTypes,
30911 value: checkedBlockNames,
30912 onItemChange: toggleVisible
30913 })]
30914 });
30915 }
30916 /* harmony default export */ const block_manager_category = (BlockManagerCategory);
30917
30918 ;// ./packages/editor/build-module/components/block-manager/index.js
30919 /**
30920 * WordPress dependencies
30921 */
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931 /**
30932 * Internal dependencies
30933 */
30934
30935
30936
30937
30938 function BlockManager() {
30939 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
30940 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
30941 const {
30942 showBlockTypes
30943 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
30944 const {
30945 blockTypes,
30946 categories,
30947 hasBlockSupport,
30948 isMatchingSearchTerm,
30949 numberOfHiddenBlocks
30950 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30951 var _select$get;
30952 // Some hidden blocks become unregistered
30953 // by removing for instance the plugin that registered them, yet
30954 // they're still remain as hidden by the user's action.
30955 // We consider "hidden", blocks which were hidden and
30956 // are still registered.
30957 const _blockTypes = select(external_wp_blocks_namespaceObject.store).getBlockTypes();
30958 const hiddenBlockTypes = ((_select$get = select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _select$get !== void 0 ? _select$get : []).filter(hiddenBlock => {
30959 return _blockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock);
30960 });
30961 return {
30962 blockTypes: _blockTypes,
30963 categories: select(external_wp_blocks_namespaceObject.store).getCategories(),
30964 hasBlockSupport: select(external_wp_blocks_namespaceObject.store).hasBlockSupport,
30965 isMatchingSearchTerm: select(external_wp_blocks_namespaceObject.store).isMatchingSearchTerm,
30966 numberOfHiddenBlocks: Array.isArray(hiddenBlockTypes) && hiddenBlockTypes.length
30967 };
30968 }, []);
30969 function enableAllBlockTypes(newBlockTypes) {
30970 const blockNames = newBlockTypes.map(({
30971 name
30972 }) => name);
30973 showBlockTypes(blockNames);
30974 }
30975 const filteredBlockTypes = blockTypes.filter(blockType => hasBlockSupport(blockType, 'inserter', true) && (!search || isMatchingSearchTerm(blockType, search)) && (!blockType.parent || blockType.parent.includes('core/post-content')));
30976
30977 // Announce search results on change
30978 (0,external_wp_element_namespaceObject.useEffect)(() => {
30979 if (!search) {
30980 return;
30981 }
30982 const count = filteredBlockTypes.length;
30983 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %d: number of results. */
30984 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
30985 debouncedSpeak(resultsFoundMessage);
30986 }, [filteredBlockTypes?.length, search, debouncedSpeak]);
30987 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30988 className: "editor-block-manager__content",
30989 children: [!!numberOfHiddenBlocks && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30990 className: "editor-block-manager__disabled-blocks-count",
30991 children: [(0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %d: number of blocks. */
30992 (0,external_wp_i18n_namespaceObject._n)('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
30993 __next40pxDefaultSize: true,
30994 variant: "link",
30995 onClick: () => enableAllBlockTypes(filteredBlockTypes),
30996 children: (0,external_wp_i18n_namespaceObject.__)('Reset')
30997 })]
30998 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SearchControl, {
30999 __nextHasNoMarginBottom: true,
31000 label: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
31001 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
31002 value: search,
31003 onChange: nextSearch => setSearch(nextSearch),
31004 className: "editor-block-manager__search"
31005 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
31006 tabIndex: "0",
31007 role: "region",
31008 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Available block types'),
31009 className: "editor-block-manager__results",
31010 children: [filteredBlockTypes.length === 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
31011 className: "editor-block-manager__no-results",
31012 children: (0,external_wp_i18n_namespaceObject.__)('No blocks found.')
31013 }), categories.map(category => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager_category, {
31014 title: category.title,
31015 blockTypes: filteredBlockTypes.filter(blockType => blockType.category === category.slug)
31016 }, category.slug)), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager_category, {
31017 title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized'),
31018 blockTypes: filteredBlockTypes.filter(({
31019 category
31020 }) => !category)
31021 })]
31022 })]
31023 });
31024 }
31025
31026 ;// ./packages/editor/build-module/components/preferences-modal/index.js
31027 /**
31028 * WordPress dependencies
31029 */
31030
31031
31032
31033
31034
31035
31036
31037
31038 /**
31039 * Internal dependencies
31040 */
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054 const {
31055 PreferencesModal,
31056 PreferencesModalTabs,
31057 PreferencesModalSection,
31058 PreferenceToggleControl
31059 } = unlock(external_wp_preferences_namespaceObject.privateApis);
31060 function EditorPreferencesModal({
31061 extraSections = {}
31062 }) {
31063 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
31064 const {
31065 isActive,
31066 showBlockBreadcrumbsOption
31067 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31068 const {
31069 getEditorSettings
31070 } = select(store_store);
31071 const {
31072 get
31073 } = select(external_wp_preferences_namespaceObject.store);
31074 const {
31075 isModalActive
31076 } = select(store);
31077 const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
31078 const isDistractionFreeEnabled = get('core', 'distractionFree');
31079 return {
31080 showBlockBreadcrumbsOption: !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled,
31081 isActive: isModalActive('editor/preferences')
31082 };
31083 }, [isLargeViewport]);
31084 const {
31085 closeModal
31086 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
31087 const {
31088 setIsListViewOpened,
31089 setIsInserterOpened
31090 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
31091 const {
31092 set: setPreference
31093 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
31094 const hasStarterPatterns = !!useStartPatterns().length;
31095 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{
31096 name: 'general',
31097 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'),
31098 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
31099 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
31100 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
31101 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31102 scope: "core",
31103 featureName: "showListViewByDefault",
31104 help: (0,external_wp_i18n_namespaceObject.__)('Opens the List View sidebar by default.'),
31105 label: (0,external_wp_i18n_namespaceObject.__)('Always open List View')
31106 }), showBlockBreadcrumbsOption && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31107 scope: "core",
31108 featureName: "showBlockBreadcrumbs",
31109 help: (0,external_wp_i18n_namespaceObject.__)('Display the block hierarchy trail at the bottom of the editor.'),
31110 label: (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs')
31111 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31112 scope: "core",
31113 featureName: "allowRightClickOverrides",
31114 help: (0,external_wp_i18n_namespaceObject.__)('Allows contextual List View menus via right-click, overriding browser defaults.'),
31115 label: (0,external_wp_i18n_namespaceObject.__)('Allow right-click contextual menus')
31116 }), hasStarterPatterns && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31117 scope: "core",
31118 featureName: "enableChoosePatternModal",
31119 help: (0,external_wp_i18n_namespaceObject.__)('Shows starter patterns when creating a new page.'),
31120 label: (0,external_wp_i18n_namespaceObject.__)('Show starter patterns')
31121 })]
31122 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
31123 title: (0,external_wp_i18n_namespaceObject.__)('Document settings'),
31124 description: (0,external_wp_i18n_namespaceObject.__)('Select what settings are shown in the document panel.'),
31125 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel.Slot, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
31126 taxonomyWrapper: (content, taxonomy) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
31127 label: taxonomy.labels.menu_name,
31128 panelName: `taxonomy-panel-${taxonomy.slug}`
31129 })
31130 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
31131 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
31132 label: (0,external_wp_i18n_namespaceObject.__)('Featured image'),
31133 panelName: "featured-image"
31134 })
31135 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
31136 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
31137 label: (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
31138 panelName: "post-excerpt"
31139 })
31140 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
31141 supportKeys: ['comments', 'trackbacks'],
31142 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
31143 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
31144 panelName: "discussion-panel"
31145 })
31146 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
31147 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
31148 label: (0,external_wp_i18n_namespaceObject.__)('Page attributes'),
31149 panelName: "page-attributes"
31150 })
31151 })]
31152 }), isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
31153 title: (0,external_wp_i18n_namespaceObject.__)('Publishing'),
31154 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_publish_sidebar, {
31155 help: (0,external_wp_i18n_namespaceObject.__)('Review settings, such as visibility and tags.'),
31156 label: (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks')
31157 })
31158 }), extraSections?.general]
31159 })
31160 }, {
31161 name: 'appearance',
31162 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
31163 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
31164 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
31165 description: (0,external_wp_i18n_namespaceObject.__)('Customize the editor interface to suit your needs.'),
31166 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31167 scope: "core",
31168 featureName: "fixedToolbar",
31169 onToggle: () => setPreference('core', 'distractionFree', false),
31170 help: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place.'),
31171 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar')
31172 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31173 scope: "core",
31174 featureName: "distractionFree",
31175 onToggle: () => {
31176 setPreference('core', 'fixedToolbar', true);
31177 setIsInserterOpened(false);
31178 setIsListViewOpened(false);
31179 },
31180 help: (0,external_wp_i18n_namespaceObject.__)('Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'),
31181 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free')
31182 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31183 scope: "core",
31184 featureName: "focusMode",
31185 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'),
31186 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode')
31187 }), extraSections?.appearance]
31188 })
31189 }, {
31190 name: 'accessibility',
31191 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Accessibility'),
31192 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
31193 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
31194 title: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
31195 description: (0,external_wp_i18n_namespaceObject.__)('Optimize the editing experience for enhanced control.'),
31196 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31197 scope: "core",
31198 featureName: "keepCaretInsideBlock",
31199 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.'),
31200 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block')
31201 })
31202 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
31203 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
31204 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31205 scope: "core",
31206 featureName: "showIconLabels",
31207 label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'),
31208 help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons across the interface.')
31209 })
31210 })]
31211 })
31212 }, {
31213 name: 'blocks',
31214 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
31215 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
31216 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
31217 title: (0,external_wp_i18n_namespaceObject.__)('Inserter'),
31218 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31219 scope: "core",
31220 featureName: "mostUsedBlocks",
31221 help: (0,external_wp_i18n_namespaceObject.__)('Adds a category with the most frequently used blocks in the inserter.'),
31222 label: (0,external_wp_i18n_namespaceObject.__)('Show most used blocks')
31223 })
31224 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
31225 title: (0,external_wp_i18n_namespaceObject.__)('Manage block visibility'),
31226 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."),
31227 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockManager, {})
31228 })]
31229 })
31230 }, window.__experimentalMediaProcessing && {
31231 name: 'media',
31232 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Media'),
31233 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
31234 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
31235 title: (0,external_wp_i18n_namespaceObject.__)('General'),
31236 description: (0,external_wp_i18n_namespaceObject.__)('Customize options related to the media upload flow.'),
31237 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31238 scope: "core/media",
31239 featureName: "optimizeOnUpload",
31240 help: (0,external_wp_i18n_namespaceObject.__)('Compress media items before uploading to the server.'),
31241 label: (0,external_wp_i18n_namespaceObject.__)('Pre-upload compression')
31242 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
31243 scope: "core/media",
31244 featureName: "requireApproval",
31245 help: (0,external_wp_i18n_namespaceObject.__)('Require approval step when optimizing existing media.'),
31246 label: (0,external_wp_i18n_namespaceObject.__)('Approval step')
31247 })]
31248 })
31249 })
31250 }].filter(Boolean), [showBlockBreadcrumbsOption, extraSections, setIsInserterOpened, setIsListViewOpened, setPreference, isLargeViewport, hasStarterPatterns]);
31251 if (!isActive) {
31252 return null;
31253 }
31254 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModal, {
31255 closeModal: closeModal,
31256 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalTabs, {
31257 sections: sections
31258 })
31259 });
31260 }
31261
31262 ;// ./packages/editor/build-module/bindings/pattern-overrides.js
31263 /**
31264 * WordPress dependencies
31265 */
31266
31267 const CONTENT = 'content';
31268 /* harmony default export */ const pattern_overrides = ({
31269 name: 'core/pattern-overrides',
31270 getValues({
31271 select,
31272 clientId,
31273 context,
31274 bindings
31275 }) {
31276 const patternOverridesContent = context['pattern/overrides'];
31277 const {
31278 getBlockAttributes
31279 } = select(external_wp_blockEditor_namespaceObject.store);
31280 const currentBlockAttributes = getBlockAttributes(clientId);
31281 const overridesValues = {};
31282 for (const attributeName of Object.keys(bindings)) {
31283 const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
31284
31285 // If it has not been overriden, return the original value.
31286 // Check undefined because empty string is a valid value.
31287 if (overridableValue === undefined) {
31288 overridesValues[attributeName] = currentBlockAttributes[attributeName];
31289 continue;
31290 } else {
31291 overridesValues[attributeName] = overridableValue === '' ? undefined : overridableValue;
31292 }
31293 }
31294 return overridesValues;
31295 },
31296 setValues({
31297 select,
31298 dispatch,
31299 clientId,
31300 bindings
31301 }) {
31302 const {
31303 getBlockAttributes,
31304 getBlockParentsByBlockName,
31305 getBlocks
31306 } = select(external_wp_blockEditor_namespaceObject.store);
31307 const currentBlockAttributes = getBlockAttributes(clientId);
31308 const blockName = currentBlockAttributes?.metadata?.name;
31309 if (!blockName) {
31310 return;
31311 }
31312 const [patternClientId] = getBlockParentsByBlockName(clientId, 'core/block', true);
31313
31314 // Extract the updated attributes from the source bindings.
31315 const attributes = Object.entries(bindings).reduce((attrs, [key, {
31316 newValue
31317 }]) => {
31318 attrs[key] = newValue;
31319 return attrs;
31320 }, {});
31321
31322 // If there is no pattern client ID, sync blocks with the same name and same attributes.
31323 if (!patternClientId) {
31324 const syncBlocksWithSameName = blocks => {
31325 for (const block of blocks) {
31326 if (block.attributes?.metadata?.name === blockName) {
31327 dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(block.clientId, attributes);
31328 }
31329 syncBlocksWithSameName(block.innerBlocks);
31330 }
31331 };
31332 syncBlocksWithSameName(getBlocks());
31333 return;
31334 }
31335 const currentBindingValue = getBlockAttributes(patternClientId)?.[CONTENT];
31336 dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(patternClientId, {
31337 [CONTENT]: {
31338 ...currentBindingValue,
31339 [blockName]: {
31340 ...currentBindingValue?.[blockName],
31341 ...Object.entries(attributes).reduce((acc, [key, value]) => {
31342 // TODO: We need a way to represent `undefined` in the serialized overrides.
31343 // Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
31344 // We use an empty string to represent undefined for now until
31345 // we support a richer format for overrides and the block bindings API.
31346 acc[key] = value === undefined ? '' : value;
31347 return acc;
31348 }, {})
31349 }
31350 }
31351 });
31352 },
31353 canUserEditValue: () => true
31354 });
31355
31356 ;// ./packages/editor/build-module/bindings/post-meta.js
31357 /**
31358 * WordPress dependencies
31359 */
31360
31361
31362 /**
31363 * Internal dependencies
31364 */
31365
31366
31367
31368 /**
31369 * Gets a list of post meta fields with their values and labels
31370 * to be consumed in the needed callbacks.
31371 * If the value is not available based on context, like in templates,
31372 * it falls back to the default value, label, or key.
31373 *
31374 * @param {Object} select The select function from the data store.
31375 * @param {Object} context The context provided.
31376 * @return {Object} List of post meta fields with their value and label.
31377 *
31378 * @example
31379 * ```js
31380 * {
31381 * field_1_key: {
31382 * label: 'Field 1 Label',
31383 * value: 'Field 1 Value',
31384 * },
31385 * field_2_key: {
31386 * label: 'Field 2 Label',
31387 * value: 'Field 2 Value',
31388 * },
31389 * ...
31390 * }
31391 * ```
31392 */
31393 function getPostMetaFields(select, context) {
31394 const {
31395 getEditedEntityRecord
31396 } = select(external_wp_coreData_namespaceObject.store);
31397 const {
31398 getRegisteredPostMeta
31399 } = unlock(select(external_wp_coreData_namespaceObject.store));
31400 let entityMetaValues;
31401 // Try to get the current entity meta values.
31402 if (context?.postType && context?.postId) {
31403 entityMetaValues = getEditedEntityRecord('postType', context?.postType, context?.postId).meta;
31404 }
31405 const registeredFields = getRegisteredPostMeta(context?.postType);
31406 const metaFields = {};
31407 Object.entries(registeredFields || {}).forEach(([key, props]) => {
31408 // Don't include footnotes or private fields.
31409 if (key !== 'footnotes' && key.charAt(0) !== '_') {
31410 var _entityMetaValues$key;
31411 metaFields[key] = {
31412 label: props.title || key,
31413 value: // When using the entity value, an empty string IS a valid value.
31414 (_entityMetaValues$key = entityMetaValues?.[key]) !== null && _entityMetaValues$key !== void 0 ? _entityMetaValues$key :
31415 // When using the default, an empty string IS NOT a valid value.
31416 props.default || undefined,
31417 type: props.type
31418 };
31419 }
31420 });
31421 if (!Object.keys(metaFields || {}).length) {
31422 return null;
31423 }
31424 return metaFields;
31425 }
31426 /* harmony default export */ const post_meta = ({
31427 name: 'core/post-meta',
31428 getValues({
31429 select,
31430 context,
31431 bindings
31432 }) {
31433 const metaFields = getPostMetaFields(select, context);
31434 const newValues = {};
31435 for (const [attributeName, source] of Object.entries(bindings)) {
31436 var _ref;
31437 // Use the value, the field label, or the field key.
31438 const fieldKey = source.args.key;
31439 const {
31440 value: fieldValue,
31441 label: fieldLabel
31442 } = metaFields?.[fieldKey] || {};
31443 newValues[attributeName] = (_ref = fieldValue !== null && fieldValue !== void 0 ? fieldValue : fieldLabel) !== null && _ref !== void 0 ? _ref : fieldKey;
31444 }
31445 return newValues;
31446 },
31447 setValues({
31448 dispatch,
31449 context,
31450 bindings
31451 }) {
31452 const newMeta = {};
31453 Object.values(bindings).forEach(({
31454 args,
31455 newValue
31456 }) => {
31457 newMeta[args.key] = newValue;
31458 });
31459 dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', context?.postType, context?.postId, {
31460 meta: newMeta
31461 });
31462 },
31463 canUserEditValue({
31464 select,
31465 context,
31466 args
31467 }) {
31468 // Lock editing in query loop.
31469 if (context?.query || context?.queryId) {
31470 return false;
31471 }
31472 const postType = context?.postType || select(store_store).getCurrentPostType();
31473
31474 // Check that editing is happening in the post editor and not a template.
31475 if (postType === 'wp_template') {
31476 return false;
31477 }
31478 const fieldValue = getPostMetaFields(select, context)?.[args.key]?.value;
31479 // Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
31480 if (fieldValue === undefined) {
31481 return false;
31482 }
31483 // Check that custom fields metabox is not enabled.
31484 const areCustomFieldsEnabled = select(store_store).getEditorSettings().enableCustomFields;
31485 if (areCustomFieldsEnabled) {
31486 return false;
31487 }
31488
31489 // Check that the user has the capability to edit post meta.
31490 const canUserEdit = select(external_wp_coreData_namespaceObject.store).canUser('update', {
31491 kind: 'postType',
31492 name: context?.postType,
31493 id: context?.postId
31494 });
31495 if (!canUserEdit) {
31496 return false;
31497 }
31498 return true;
31499 },
31500 getFieldsList({
31501 select,
31502 context
31503 }) {
31504 return getPostMetaFields(select, context);
31505 }
31506 });
31507
31508 ;// ./packages/editor/build-module/bindings/api.js
31509 /**
31510 * WordPress dependencies
31511 */
31512
31513
31514 /**
31515 * Internal dependencies
31516 */
31517
31518
31519
31520 /**
31521 * Function to register core block bindings sources provided by the editor.
31522 *
31523 * @example
31524 * ```js
31525 * import { registerCoreBlockBindingsSources } from '@wordpress/editor';
31526 *
31527 * registerCoreBlockBindingsSources();
31528 * ```
31529 */
31530 function registerCoreBlockBindingsSources() {
31531 (0,external_wp_blocks_namespaceObject.registerBlockBindingsSource)(pattern_overrides);
31532 (0,external_wp_blocks_namespaceObject.registerBlockBindingsSource)(post_meta);
31533 }
31534
31535 ;// ./packages/editor/build-module/private-apis.js
31536 /**
31537 * WordPress dependencies
31538 */
31539
31540
31541 /**
31542 * Internal dependencies
31543 */
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559 const {
31560 store: interfaceStore,
31561 ...remainingInterfaceApis
31562 } = build_module_namespaceObject;
31563 const privateApis = {};
31564 lock(privateApis, {
31565 CreateTemplatePartModal: CreateTemplatePartModal,
31566 BackButton: back_button,
31567 EntitiesSavedStatesExtensible: EntitiesSavedStatesExtensible,
31568 Editor: editor,
31569 EditorContentSlotFill: content_slot_fill,
31570 GlobalStylesProvider: GlobalStylesProvider,
31571 mergeBaseAndUserConfigs: mergeBaseAndUserConfigs,
31572 PluginPostExcerpt: post_excerpt_plugin,
31573 PostCardPanel: PostCardPanel,
31574 PreferencesModal: EditorPreferencesModal,
31575 usePostActions: usePostActions,
31576 ToolsMoreMenuGroup: tools_more_menu_group,
31577 ViewMoreMenuGroup: view_more_menu_group,
31578 ResizableEditor: resizable_editor,
31579 registerCoreBlockBindingsSources: registerCoreBlockBindingsSources,
31580 // This is a temporary private API while we're updating the site editor to use EditorProvider.
31581 interfaceStore,
31582 ...remainingInterfaceApis
31583 });
31584
31585 ;// ./packages/editor/build-module/dataviews/api.js
31586 /**
31587 * WordPress dependencies
31588 */
31589
31590
31591 /**
31592 * Internal dependencies
31593 */
31594
31595
31596
31597 /**
31598 * @typedef {import('@wordpress/dataviews').Action} Action
31599 */
31600
31601 /**
31602 * Registers a new DataViews action.
31603 *
31604 * This is an experimental API and is subject to change.
31605 * it's only available in the Gutenberg plugin for now.
31606 *
31607 * @param {string} kind Entity kind.
31608 * @param {string} name Entity name.
31609 * @param {Action} config Action configuration.
31610 */
31611
31612 function api_registerEntityAction(kind, name, config) {
31613 const {
31614 registerEntityAction: _registerEntityAction
31615 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
31616 if (true) {
31617 _registerEntityAction(kind, name, config);
31618 }
31619 }
31620
31621 /**
31622 * Unregisters a DataViews action.
31623 *
31624 * This is an experimental API and is subject to change.
31625 * it's only available in the Gutenberg plugin for now.
31626 *
31627 * @param {string} kind Entity kind.
31628 * @param {string} name Entity name.
31629 * @param {string} actionId Action ID.
31630 */
31631 function api_unregisterEntityAction(kind, name, actionId) {
31632 const {
31633 unregisterEntityAction: _unregisterEntityAction
31634 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
31635 if (true) {
31636 _unregisterEntityAction(kind, name, actionId);
31637 }
31638 }
31639
31640 ;// ./packages/editor/build-module/index.js
31641 /**
31642 * Internal dependencies
31643 */
31644
31645
31646
31647
31648
31649
31650
31651 /*
31652 * Backward compatibility
31653 */
31654
31655
31656 })();
31657
31658 (window.wp = window.wp || {}).editor = __webpack_exports__;
31659 /******/ })()
31660 ;